A traffic screening collection method, system, computer device and storage medium
By employing a traffic filtering and collection method based on kernel bypass mode and multi-dimensional feature matching, combined with protocol feature library self-identification and a pluggable parser, the problems of low identification accuracy and insufficient adaptability in existing technologies are solved, achieving efficient protocol identification and session reassembly, and adapting to complex network environments.
Patent Information
- Application Number
- CN202611694233.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-10-30
- Publication Date
- 2026-11-27
AI Technical Summary
Existing traffic parsing and filtering technologies have low accuracy in identifying and filtering when faced with dynamic port protocols, port reuse, and complex network environments. They cannot effectively reconstruct complete bidirectional business sessions, and solutions that rely on specific device log outputs lack versatility and flexibility.
It adopts kernel bypass mode to collect network data packets, and achieves dynamic self-identification of protocols and session reassembly through multi-dimensional feature matching and protocol feature library self-identification, combined with pluggable protocol parser and rule engine. It also supports online incremental updates of protocol feature library and discovery of unknown protocols.
It significantly improves the accuracy of protocol identification and session reassembly, adapts to complex network scenarios, reduces system overhead, improves processing efficiency and flexibility, and supports dynamic protocol identification and adaptation to new protocols.
Smart Images

Figure CN123185288A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data processing technology, specifically to a traffic filtering and acquisition method, system, computer equipment, and storage medium. Background Technology
[0002] With the rapid development of internet and big data technologies, network traffic analysis and data security management face ever-increasing challenges. Network services are becoming increasingly complex and diverse, and network link bandwidth is constantly improving. The efficient processing and accurate filtering of massive amounts of traffic has become a crucial issue in the field of cybersecurity. Enterprises need to conduct in-depth analysis and auditing of specific network data to monitor security risks such as network attacks and sensitive data breaches.
[0003] However, existing traffic parsing and filtering technologies still have many shortcomings: On the one hand, traditional traffic analysis systems typically filter specific data by manually setting static traffic filtering rules. They can only identify standard protocols based on fixed ports, resulting in poor operational flexibility. When faced with dynamic port protocols, port reuse scenarios, and custom protocols, the accuracy of identification and filtering drops significantly, making it difficult to set precise traffic control strategies in complex network environments.
[0004] On the other hand, the widespread deployment of NAT devices in the network causes changes in the source IP address and port information of network traffic after address translation, rendering traditional session association methods based on IP address and port ineffective. Although there are improved solutions such as NAT log association and session cache management, these solutions generally rely on the log output of specific devices, lacking versatility and flexibility. Especially when facing complex forwarding scenarios such as Layer 7 proxies and load balancers, they cannot provide accurate session association capabilities and are unable to reconstruct complete bidirectional business sessions.
[0005] Therefore, there is an urgent need for a traffic collection and filtering technology that can automatically identify protocol types, accurately reconstruct business sessions, and flexibly implement traffic filtering to solve the above-mentioned problems in existing technologies and meet the growing demand for network traffic analysis and security management. Summary of the Invention
[0006] A first aspect of the present invention provides a traffic filtering and collection method, comprising: S1. In user space, network data packets are collected using kernel bypass mode. Data packets from multiple network interface card (NIC) receiving queues are distributed to the corresponding collection threads using the receiving end scaling hash rule to obtain the raw data packet stream. S2. Parse the data link layer, network layer, and transport layer protocol headers of each data packet in the original data packet stream, and extract the five-tuple information, packet length, timestamp, and payload preamble sequence; according to the five-tuple information, group the data packets into several data streams to be identified, and generate the packet length sequence, time interval sequence, and payload sampling set corresponding to each data stream to be identified; S3. Construct a multi-dimensional feature vector of the data stream to be identified, calculate the similarity between the multi-dimensional feature vector and the feature vector of each known protocol standard based on the pre-constructed protocol feature library, and obtain a similarity set; when the similarity set meets the preset judgment conditions, output the corresponding protocol type identifier and recognition confidence; when it does not meet the conditions, mark the data stream to be identified as a pending protocol data stream and perform secondary recognition. S4. Based on the protocol type identifier, schedule a matching target protocol parser from the set of pluggable protocol parsers to perform deep parsing of the data stream to be identified, extract key metadata and label the asset type. S5. Combine the five-tuple information with the protocol type identifier to form a session identifier. Combine the time sliding window to reassemble data packets with the same session identifier into a bidirectional session stream. When the timeout elimination condition is met, close the corresponding session while retaining the business context semantic information. S6. Input the bidirectional session stream carrying the key metadata and asset type labels into the rule engine, perform matching processing according to the preset rule base, output the matching result, the matching content and its offset in the original data packet and store it.
[0007] In one possible implementation, constructing the multidimensional feature vector of the data stream to be identified includes: Extract the source port and destination port of the data stream to be identified, and compare them with a preset well-known port number to obtain port feature components; The packet length distribution feature component is obtained by statistically analyzing the packet length sequence, the temporal feature component is obtained by statistically analyzing the time interval sequence, and the load entropy value feature component is obtained by calculating the information entropy of the load sampling set. The uplink and downlink directional parameters are extracted to obtain directional feature components; After normalizing each feature component, they are concatenated according to their dimensions to obtain the multidimensional feature vector.
[0008] In one possible implementation, the construction of a multidimensional feature vector for the data stream to be identified involves calculating the similarity between the multidimensional feature vector and the standard feature vectors of each known protocol based on a pre-built protocol feature library, thereby obtaining a similarity set. When the similarity set meets a preset judgment condition, the corresponding protocol type identifier and identification confidence level are output. If the condition is not met, the data stream to be identified is marked as a pending protocol data stream and a secondary identification is performed, including: For each known protocol in the protocol feature library, the sub-similarity of the multi-dimensional feature vector and the standard feature vector of the known protocol in each feature dimension is calculated, and the comprehensive similarity is obtained by weighting and fusing them according to the corresponding weight coefficients. The similarity set is obtained by traversing the protocol feature library and sorted in descending order of comprehensive similarity. When the overall similarity of the first and second ranked items is not less than the identification confidence threshold, and the difference in overall similarity between the first and second ranked items is greater than the confidence difference threshold, the known protocol corresponding to the first ranked item is determined to be the protocol type of the data stream to be identified; otherwise, it is marked as a data stream with an undetermined protocol. The weighting coefficients are dynamically adjusted based on the inter-class dispersion of each feature dimension in the protocol feature library; the greater the inter-class dispersion, the greater the weight. The recognition confidence threshold and the confidence difference threshold are dynamically adjusted based on the semantic verification accuracy of the recognition results within a preset period.
[0009] In one possible implementation, the secondary identification includes: Expand the sampling window of the pending protocol data stream, increase the number of data packets participating in the statistics, and supplement at least one dimension of protocol keyword features, byte n-gram grammar fingerprint features, and transport layer security protocol handshake features to reconstruct an extended multidimensional feature vector; The extended multidimensional feature vector is re-matched with the protocol feature library for similarity; if the first and second comprehensive similarity after matching is not less than the recognition confidence threshold, the corresponding protocol type is determined. If the conditions are still not met, the deep packet inspection fingerprint database is invoked to match the payload leading byte sequence with the protocol fingerprint regular expression in the fingerprint database. If the match is successful, the corresponding protocol type is determined; if the match still fails, the data stream is marked as an unknown protocol data stream.
[0010] In one possible implementation, the step of scheduling a matching target protocol parser from a set of pluggable protocol parsers based on the protocol type identifier to perform deep parsing of the data stream to be identified, extract key metadata, and label the asset type includes: comparing the identification confidence score with a parsing path switching threshold; if the confidence score is not less than the parsing path switching threshold, scheduling to a fast parsing path and directly extracting key metadata according to the corresponding field offset template; if the confidence score is less than the parsing path switching threshold, scheduling to a complete parsing path and performing full field parsing and semantic verification.
[0011] In one possible implementation, the method further includes online incremental updates of the protocol signature database and steps for discovering unknown protocols, specifically including: For identified data streams with an identification confidence level not lower than the feature library update confidence level threshold, an exponentially weighted moving average algorithm is used to incrementally update the standard feature vector of the corresponding known protocol, and the sample count is updated synchronously. The extended multidimensional feature vectors of all unknown protocol data streams are clustered to obtain several candidate protocol clusters. When the number of samples in a candidate protocol cluster is not less than a set number and the duration is not less than a set duration, it is determined to be a stable protocol cluster, and a protocol type identifier and an initial standard feature vector are generated and registered in the protocol feature library.
[0012] A second aspect of the present invention provides a traffic filtering and acquisition system, comprising: The data acquisition module is used to acquire network data packets in user space using kernel bypass mode, where the data packets are not processed by the kernel protocol stack; the data packets of the multi-NIC receive queue are distributed to the corresponding acquisition threads according to the receiving end scaling hash rule to obtain the raw data packet stream; The data preprocessing module is used to parse the data link layer, network layer, and transport layer protocol headers of each data packet in the original data packet stream, extract the five-tuple information, packet length, timestamp, and payload preamble byte sequence; according to the five-tuple information, the data packets are grouped into several data streams to be identified, and the packet length sequence, time interval sequence, and payload sampling set corresponding to each data stream to be identified are generated; The protocol self-identification module is used to construct a multi-dimensional feature vector of the data stream to be identified, calculate the similarity between the multi-dimensional feature vector and the standard feature vectors of each known protocol in the protocol feature library based on a pre-built protocol feature library, and obtain a similarity set; when the similarity set meets the preset judgment conditions, the corresponding protocol type identifier and identification confidence level are output; when not, the data stream to be identified is marked as a pending protocol data stream and a secondary identification is performed. The pluggable protocol parsing module is used to schedule a matching target protocol parser from the set of pluggable protocol parsers according to the protocol type identifier, perform deep parsing on the data stream to be identified, extract key metadata, and label the asset type. The session reassembly module is used to combine the five-tuple information with the protocol type identifier to form a session identifier, and combine a time sliding window to reassemble data packets with the same session identifier into a bidirectional session stream; when the timeout elimination condition is met, the corresponding session is closed while retaining the business context semantic information. The rule filtering module is used to input the bidirectional session stream carrying the key metadata and asset type labels into the rule engine, perform matching processing according to the preset rule base, output the matching result, the matching content and its offset in the original data packet and store it.
[0013] In one possible implementation, the system further includes a pipeline scheduling module; The data pre-processing module, protocol self-identification module, pluggable protocol parsing module, session reassembly module, and rule filtering module are multiple loosely coupled independent processing stages, each of which is bound to different processing cores of a multi-core processor for parallel execution. Data batches are transmitted between different processing stages via asynchronous message queues; The pipeline scheduling module monitors the system load in real time and dynamically adjusts the batch processing data volume of each processing stage according to the system load: when the system load is lower than the preset load threshold, small batch processing is used to reduce processing latency; when the system load is higher than the preset load threshold, large batch processing is used to increase processing throughput.
[0014] A third aspect of the present invention provides a computer device including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the traffic filtering and acquisition method as described in the first aspect of the present invention.
[0015] A fourth aspect of the present invention provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the traffic filtering and acquisition method as described in the first aspect of the present invention.
[0016] Compared with the prior art, the beneficial effects of the present invention are: By achieving dynamic self-identification of protocols through multi-dimensional feature matching, and completing session reassembly by combining a session identifier method based on a combination of 5-tuples and protocol types, coupled with pluggable deep parsing and rule engine matching, compared with traditional static port identification and pure 5-tuple session association, it significantly improves the accuracy of protocol identification, the precision of session reassembly, and the flexibility of traffic filtering, and can effectively adapt to complex network scenarios such as dynamic ports and port reuse.
[0017] It adopts a secondary recognition fallback mechanism to improve protocol recognition coverage while ensuring recognition efficiency; it supports dual adaptive adjustment of weight and threshold, and can dynamically balance recognition accuracy and coverage according to actual operation results; the protocol feature library can be updated incrementally online and autonomously discover unknown protocols without the need for continuous manual maintenance, and adapt to protocol evolution and new protocol scenarios.
[0018] It adopts a multi-stage, loosely coupled pipelined parallel architecture, with each stage bound to an independent processing core. The batch processing data volume is dynamically adjusted according to the system load, which can adaptively balance the processing latency in low-load scenarios and the processing throughput in high-load scenarios, giving full play to the performance of multi-core hardware. The pluggable protocol parser architecture supports on-demand loading and unloading, flexibly expanding the parsing capabilities of different protocols. Attached Figure Description
[0019] Figure 1This is a flowchart illustrating the traffic filtering and collection method of the present invention; Figure 2 This is a schematic diagram of the traffic filtering and acquisition system of the present invention; Figure 3 This is a schematic diagram of a computer device according to an embodiment of the present invention. Detailed Implementation
[0020] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0021] It should be noted that the serial numbers assigned to the components in the embodiments of the present invention, such as "first" and "second", are only used to distinguish the described objects and have no sequential or technical meaning.
[0022] The following is combined Figure 1 A traffic filtering and collection method of the present invention is described.
[0023] A traffic filtering and collection method includes six core processing steps: user-space bypass collection, packet pre-organization and aggregation, dynamic protocol self-identification, pluggable deep parsing, session reassembly, and rule filtering. It is supported by a protocol feature library self-learning mechanism and a multi-core pipeline scheduling mechanism. The specific implementation of each step is as follows: S1, User-mode bypass data acquisition: This method uses a kernel bypass mode to collect network packets in user space. The packets are directly mapped from the network card hardware queue to the user space memory, bypassing the protocol parsing and queuing processes of the kernel protocol stack. Traditional kernel-mode collection methods involve kernel interrupt responses, layer-by-layer protocol stack processing, and multiple memory copies, resulting in high system overhead and processing latency, and are prone to packet loss under high bandwidth traffic scenarios. This step bypasses the kernel protocol stack path, significantly reducing the system overhead of the collection process and improving the stability of collection under high traffic.
[0024] Hardware queue distribution is achieved using a Receiver Scaling (RSS) hashing mechanism: the network interface card (NIC) hardware calculates a hash value based on the 5-tuple information of the data packets and distributes the traffic to its multiple hardware receive queues. Each receive queue is bound to an independent acquisition thread, and data packets from the same data stream always enter the same receive queue. This approach ensures the consistency of the order of data packets within the same stream, avoiding the overhead of out-of-order reassembly, and improves the overall acquisition throughput through parallel acquisition by multiple queues and threads, ultimately yielding the original data packet stream.
[0025] S2. Packet pre-processing and data stream aggregation: The original data packet stream undergoes layer-by-layer protocol header parsing: the data link layer header, network layer header, and transport layer header are parsed sequentially to accurately locate the offset positions of each layer's fields and the start position of the payload. The five-tuple information, packet length, receive timestamp, and preamble sequence of the payload for each packet are extracted. The five-tuple information includes the source IP address, destination IP address, source port, destination port, and transport layer protocol type. Layer-by-layer parsing ensures the accuracy of the extracted fields, providing a reliable data foundation for subsequent flow-level statistical analysis.
[0026] Based on the 5-tuple information, a hash bucket structure is used to group the data packets in the original data packet stream into several independent data streams to be identified. The essential characteristics of the protocol type are reflected in the statistical regularity of the entire data stream. Packet-by-packet identification cannot utilize the statistical characteristics of traffic, resulting in low identification accuracy. By first grouping the data packets into independent data streams according to the 5-tuple, and then performing statistical analysis based on the entire stream, the behavioral characteristics of the traffic can be fully utilized to improve identification accuracy.
[0027] For each data stream to be identified, a packet length sequence, a time interval sequence, and a payload sampling set are generated according to the data packet reception time order, which are used for subsequent feature extraction and protocol identification.
[0028] S3, Protocol Dynamic Self-Identification: This step achieves automatic protocol type identification based on multi-dimensional feature matching. It balances identification speed, accuracy, and coverage through a progressive identification mechanism, as detailed below: 3.1 Construction of multidimensional feature vectors.
[0029] For each data stream to be identified, features are extracted from five dimensions and a multi-dimensional feature vector is constructed. The extraction methods for each dimension are as follows: Port features: Extract the source and destination ports of the data stream to be identified, compare them with a pre-defined set of well-known ports, calculate the port membership degree based on the port matching results, and obtain the port feature components.
[0030] Packet length distribution characteristics: Statistical processing is performed on the packet length sequence to calculate the mean, variance and quantile of the packet length. At the same time, the packet length range is divided into multiple equal-width intervals, and the proportion of data packets in each interval is counted to generate a packet length distribution histogram vector.
[0031] Temporal characteristics: Statistical processing is performed on the time interval sequence to calculate the packet interval mean, packet interval variance, traffic burst degree and packet rate per unit time, thus obtaining the temporal characteristic components.
[0032] Load entropy characteristics: The information entropy value is calculated for the load sampling set. The distribution characteristics of the load content are reflected by the dispersion of the byte values, and the load entropy characteristic components are obtained.
[0033] Directional characteristics: The ratio of uplink to downlink packets, the ratio of uplink to downlink bytes, and the transmission direction of the first packet in the statistical data stream are used to obtain directional characteristic components.
[0034] The feature components of the five dimensions mentioned above are normalized and mapped to a unified numerical range to eliminate the differences in the units of different features and ensure the rationality of subsequent similarity calculations; then they are concatenated in dimensional order to obtain the final multidimensional feature vector.
[0035] The traditional method of identifying protocols by relying solely on port numbers is basically ineffective in scenarios involving dynamic ports, port reuse, and encrypted protocols. By cross-validating features across five dimensions, the accuracy of protocol identification and the range of applicable scenarios can be significantly improved.
[0036] 3.2 Weighted similarity calculation and adaptive judgment, A protocol feature library is pre-built, which stores standard feature vectors of several known protocols, as well as the protocol type identifier corresponding to each standard feature vector.
[0037] For each data stream to be identified, the sub-similarity of its multi-dimensional feature vector with the standard feature vectors of each known protocol in the protocol feature library is calculated in each dimension. The sub-similarity of each dimension is then weighted and fused according to the weight coefficients corresponding to each feature dimension to obtain the comprehensive similarity for each known protocol. The comprehensive similarity is calculated as follows: ; in, The overall similarity score for the k-th known protocol. Let be the weight coefficient of the j-th feature dimension. Let be the sub-similarity of the k-th known protocol on the j-th dimension, and the sum of all weight coefficients is 1.
[0038] The algorithm iterates through all known protocols in the protocol feature library, obtaining a similarity set consisting of each protocol and its comprehensive similarity, and sorts them in descending order of comprehensive similarity. When the comprehensive similarity of the first protocol in the ranking is not less than the recognition confidence threshold, and the difference between the comprehensive similarity of the first and second protocols is greater than the confidence difference threshold, the known protocol corresponding to the first protocol in the ranking is determined as the protocol type of the data stream to be identified, and the corresponding protocol type identifier and recognition confidence score are output. Protocols that do not meet the above conditions are marked as pending protocol data streams. Using a dual judgment condition of "first protocol meeting the threshold + first and second protocol difference" can effectively avoid misjudgment of similar protocols and improve the reliability of the recognition results.
[0039] The weighting coefficients employ an adaptive adjustment mechanism: the inter-class dispersion of each feature dimension among all known protocols in the protocol feature library is statistically analyzed. Feature dimensions with greater inter-class dispersion have stronger discriminative power against protocols and are assigned larger weighting coefficients. When an update to the protocol feature library or a change in network traffic distribution is detected, the dispersion is recalculated and the weighting coefficients are updated. This mechanism allows the identification algorithm to automatically adapt to different network environments and protocol combinations, avoiding the adaptability limitations of fixed weights.
[0040] The confidence threshold and confidence difference threshold also employ an adaptive adjustment mechanism: The accuracy rate of protocol recognition results after semantic verification within a preset period is statistically analyzed. When the accuracy rate falls below the preset lower limit, both thresholds are simultaneously increased to enhance recognition strictness and reduce the false positive rate; conversely, when the accuracy rate exceeds the preset upper limit, both thresholds are simultaneously decreased to improve recognition coverage. This mechanism can dynamically adjust the judgment strictness based on actual operational performance, achieving a dynamic balance between recognition accuracy and coverage.
[0041] 3.3 Secondary identification fallback mechanism.
[0042] For data streams marked as pending protocols, secondary identification is performed using a two-tiered fallback strategy of "soft matching first, then hard matching" to maximize identification coverage while ensuring processing efficiency. The specific process is as follows: First, the sampling window of the pending protocol data stream is expanded to increase the number of data packets participating in the statistics and improve the stability of the statistical features. At the same time, at least one feature dimension is added to the multidimensional feature vector, including protocol keyword features, byte n-gram grammar fingerprint features, and transport layer security protocol handshake features, to reconstruct and expand the multidimensional feature vector and improve the distinguishability of the features.
[0043] The extended multidimensional feature vector is re-matched with the standard feature vector in the protocol feature library for similarity. If the overall similarity of the first and second matched features is not less than the recognition confidence threshold, the corresponding protocol type is determined.
[0044] If the expanded dimension rematch still fails to meet the identification criteria, the deep packet inspection fingerprint database is invoked. This database stores regular expressions for payload features of various protocols. The payload byte sequence of the data stream to be identified is matched against the protocol fingerprints in the database one by one using these regular expressions. If a match is successful, the corresponding protocol type is determined. Data streams whose protocol type still cannot be determined after secondary identification are marked as unknown protocol data streams, and their expanded multidimensional feature vectors and quintuple information are stored for subsequent protocol discovery.
[0045] Primary recognition is based on basic features with a short sampling window, which is fast but has limited recognition coverage when the sample size is insufficient. Secondary recognition takes into account both processing performance and recognition coverage by first expanding the dimensions with soft matching and then hard matching the fingerprint.
[0046] 3.4 Online incremental updates of protocol feature library and autonomous discovery of unknown protocols.
[0047] This step enables the protocol feature library to learn and iterate autonomously without requiring continuous manual maintenance. Specifically, it includes: Online incremental update: For data streams whose protocol type is determined and whose identification confidence level is not lower than the feature library update confidence threshold, an exponentially weighted moving average method is used to incrementally update the standard feature vector of the corresponding protocol using the multi-dimensional feature vector of the data stream, while simultaneously updating the sample count corresponding to the standard feature vector. The smoothing coefficient α is dynamically set according to the stability of the protocol features; the more stable the protocol features, the higher the value of α. The update method is as follows:
[0048] In the formula, For the updated standard feature vector, The standard feature vector before the update α is the feature vector of the current data stream to be identified, and α is the smoothing coefficient, with a value ranging from 0 to 1.
[0049] Network protocols can experience feature drift as versions iterate and services are upgraded. Relying entirely on manual maintenance of the feature library is not only costly but also suffers from update delays. Online incremental updates allow the feature library to continuously adapt to protocol evolution and maintain consistent recognition accuracy.
[0050] Unknown protocol clustering discovery: Clustering is performed on the extended multidimensional feature vectors of all unknown protocol data streams to aggregate unknown data streams with similar features into several candidate protocol clusters.
[0051] Stable Cluster Registration: When the number of candidate protocol clusters is not less than a set number, and the cluster persists for a set duration, it is determined to be a stable protocol cluster. The center vector of the cluster is calculated as the initial standard feature vector, a new protocol type identifier is generated for it, and it is registered in the protocol feature library, completing the autonomous discovery of unknown protocols. This mechanism can automatically identify newly emerging stable protocol types in the network without requiring manual pre-entry of protocol features, significantly reducing operation and maintenance costs and improving adaptability to new protocol environments.
[0052] S4. In-depth analysis of the pluggable protocol: Based on the identified protocol type identifier, a matching target protocol parser is scheduled from the set of pluggable protocol parsers to perform deep parsing of the data stream to be identified, extract key metadata from the protocol session content, and label the key metadata with asset type; the key metadata includes at least one of domain name, Uniform Resource Locator, file hash value, and certificate information.
[0053] The parsing process employs a dual-path scheduling mechanism to balance processing efficiency and parsing accuracy: When the recognition confidence is not less than the parsing path switching threshold, it is scheduled to the fast parsing path. For fixed-length binary protocols, it extracts key metadata directly from the specified offset position according to the predefined field offset template of the corresponding protocol, without the need for full parsing of each field, which greatly reduces processing latency and is suitable for recognition results with high confidence.
[0054] When the recognition confidence is less than the parsing path switching threshold, the system is scheduled to the complete parsing path, performs full protocol parsing of the data stream field by field, and performs semantic verification to ensure the accuracy of the parsing results. This method is suitable for recognition results with low confidence.
[0055] The protocol parser adopts a plug-in design, dynamically loading corresponding parser plugins based on the protocol type identifier. When a parser plugin remains idle for a preset duration, it is dynamically unloaded, releasing memory and computing resources. Different protocols have significantly different parsing logic, making a unified parsing architecture inflexible and costly to expand. The plug-in architecture allows for on-demand expansion of protocol parsing capabilities, and automatic unloading during idle periods improves resource utilization.
[0056] If semantic verification fails in the complete parsing path, including cases of invalid protocol format or field values exceeding reasonable ranges, the protocol type identifier of the corresponding data stream will be rolled back to a pending state, triggering a second identification process. Simultaneously, the matching boundary threshold of the corresponding protocol's standard feature vector will be adjusted to tighten the identification criteria for that protocol. This verification rollback mechanism creates negative feedback for identification errors, gradually correcting matching deviations in the feature library and continuously improving overall identification accuracy.
[0057] S5, Session Reorganization and Context Preservation: A unique session identifier is formed by combining the five-tuple information with the protocol type identifier. Combined with a time sliding window, data packets with the same session identifier are grouped into the same session bucket for session reassembly and arranged in chronological order to form a bidirectional session stream.
[0058] Traditional session identifiers based on pure 5-tuples can lead to session identifier collisions in scenarios involving transport layer connection multiplexing and multiple types of business interactions nested within the same connection, making it impossible to accurately distinguish between different business sessions. By overlaying a protocol type identifier on top of the 5-tuple, different protocol sessions on the same port can be effectively distinguished, significantly reducing the probability of session collisions and improving the accuracy of session reassembly.
[0059] The corresponding session will be closed if any of the following conditions are met: the session is closed normally when a transport layer connection closure message is detected; or the session is forced to close due to timeout when the session idle time exceeds the preset timeout threshold.
[0060] After the session is closed, the business context semantics of the bidirectional session flow are retained, including request-response correspondence, transaction interaction order, and session state. This complete business context provides comprehensive interaction logic support for subsequent rule filtering, business analysis, and threat detection, avoiding the limitations of single-packet detection.
[0061] S6, Rule Engine Matching and Filtering: The bidirectional session stream input rule engine, carrying key metadata and asset type annotations, executes at least one combination of logic matching from keyword matching, dictionary matching, and regular expression matching according to the filtering rules in the preset rule base. It supports AND, OR, and NOT logic combination configurations. A single matching method can only adapt to specific types of detection rules, which may lead to missed detections or false detections. The combination logic configuration of multiple matching methods can flexibly adapt to the traffic filtering needs of different scenarios, improving the flexibility and accuracy of rule detection.
[0062] After matching is complete, the system outputs the matching result, the matched content fragment, and the byte offset of the matched content in the original data packet, and persists these values. Outputting the offset facilitates quick location of the original data during subsequent auditing and evidence collection, improving tracing efficiency.
[0063] In this invention, the five processing stages—data pre-processing, protocol self-identification, deep parsing, session reassembly, and rule filtering—are divided into multiple loosely coupled independent processing stages. Each processing stage initiates multiple sets of parallel execution units, each bound to a different processing core of a multi-core processor, with each execution unit exclusively occupying its corresponding core. Serial processing architectures suffer from single performance bottlenecks and cannot fully utilize the computing resources of multi-core processors; the multi-stage, loosely coupled data parallel architecture can fully leverage the performance of multi-core hardware, significantly improving overall processing throughput while avoiding the overhead of process context switching and resource contention.
[0064] Data batches are transmitted between processing stages via asynchronous message queues. After the upstream stage finishes processing a batch of data, it is written to the queue, and the downstream stage reads and processes the data in batches from the queue. This achieves decoupled operation of each stage and avoids the performance bottleneck of a single stage from being transmitted to the entire link.
[0065] The system monitors CPU utilization, queue backlog length, network card bandwidth utilization, and memory usage in real time as system load indicators. Based on the system load, the batch processing data volume for each processing stage is dynamically adjusted: when the system load is below a preset load threshold, small batch processing is used to reduce the waiting time of data packets within a batch, thus lowering end-to-end processing latency; when the system load is above the preset load threshold, large batch processing is used to increase the amount of data processed per batch, avoid queue backlog and packet loss, and improve overall throughput. A fixed batch size processing mode cannot simultaneously achieve low latency and high throughput under low load; the dynamic batch processing mechanism can adapt to different load scenarios, achieving a dynamic balance between latency and throughput.
[0066] like Figure 2 As shown, the present invention also provides a traffic filtering and acquisition system, comprising: Data acquisition module 10 is used to acquire network data packets in user space using kernel bypass mode, wherein the data packets are not processed by the kernel protocol stack; the data packets of the multi-NIC receive queue are distributed to the corresponding acquisition thread by the receiving end scaling hash rule to obtain the raw data packet stream; The data preprocessing module 20 is used to parse the data link layer, network layer and transport layer protocol headers of each data packet in the original data packet stream, extract the five-tuple information, packet length, timestamp and payload preamble byte sequence; according to the five-tuple information, the data packets are grouped into several data streams to be identified, and the packet length sequence, time interval sequence and payload sampling set corresponding to each data stream to be identified are generated; The protocol self-identification module 30 is used to construct a multi-dimensional feature vector of the data stream to be identified, calculate the similarity between the multi-dimensional feature vector and the standard feature vectors of each known protocol in the protocol feature library based on a pre-built protocol feature library, and obtain a similarity set; when the similarity set meets the preset judgment conditions, the corresponding protocol type identifier and identification confidence level are output; when not, the data stream to be identified is marked as a pending protocol data stream and a secondary identification is performed. The pluggable protocol parsing module 40 is used to schedule a matching target protocol parser from the set of pluggable protocol parsers according to the protocol type identifier, perform deep parsing on the data stream to be identified, extract key metadata, and label the asset type. The session reassembly module 50 is used to combine the five-tuple information with the protocol type identifier to form a session identifier, and combine a time sliding window to reassemble data packets with the same session identifier into a bidirectional session stream; when the timeout elimination condition is met, the corresponding session is closed while retaining the business context semantic information. The rule filtering module 60 is used to input the bidirectional session stream carrying the key metadata and asset type labels into the rule engine, perform matching processing according to the preset rule library, output the matching result, the matching content and its offset in the original data packet and store it.
[0067] The data pre-processing module 20, protocol self-identification module 30, pluggable protocol parsing module 40, session reassembly module 50, and rule filtering module 60 are multiple loosely coupled independent processing stages. Each processing stage starts multiple sets of parallel execution units, which are respectively bound to different processing cores of a multi-core processor for operation. Data batches are transmitted between different processing stages via asynchronous message queues; The pipeline scheduling module 70 is used to monitor the system load in real time and dynamically adjust the batch processing data volume of each processing stage according to the system load: when the system load is lower than the preset load threshold, small batch processing is used to reduce processing latency; when the system load is higher than the preset load threshold, large batch processing is used to increase processing throughput.
[0068] In one embodiment, such as Figure 3 As shown, a computer device 80 is provided, including a memory 82, a processor 81, and a computer program 83 stored in the memory 82 and executable on the processor 81. When the processor 81 executes the computer program 83, it implements the steps in the data processing method of the above embodiments. To avoid repetition, these steps will not be described again here. Alternatively, when the processor 81 executes the computer program 83, it implements the functions of each module in the above-described traffic filtering and acquisition system embodiments. To avoid repetition, these functions will not be described again here.
[0069] In one embodiment, a readable storage medium is provided, which stores a computer program 83. When the computer program 83 is executed by the processor 81, it implements the steps in the data processing method of the above embodiments. To avoid repetition, these steps will not be repeated here. Alternatively, when the processor 81 executes the computer program 83, it implements the functions of each module in the data processing system embodiments described above. To avoid repetition, these functions will not be repeated here.
[0070] 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. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided by this invention can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAM bus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0071] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is used as an example. In practical applications, the above functions can be assigned to different functional modules, sub-modules, and units as needed, that is, the internal structure of the system can be divided into different functional units or modules to complete all or part of the functions described above.
[0072] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions 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.
Claims
1. A method for filtering and collecting traffic flow, characterized in that, include: S1. In user space, network data packets are collected using kernel bypass mode. Data packets from multiple network interface card (NIC) receiving queues are distributed to the corresponding collection threads using the receiving end scaling hash rule to obtain the raw data packet stream. S2. Parse the data link layer, network layer, and transport layer protocol headers of each data packet in the original data packet stream, and extract the five-tuple information, packet length, timestamp, and payload preamble sequence; according to the five-tuple information, group the data packets into several data streams to be identified, and generate the packet length sequence, time interval sequence, and payload sampling set corresponding to each data stream to be identified; S3. Construct a multi-dimensional feature vector of the data stream to be identified, calculate the similarity between the multi-dimensional feature vector and the feature vector of each known protocol standard based on the pre-constructed protocol feature library, and obtain a similarity set; when the similarity set meets the preset judgment conditions, output the corresponding protocol type identifier and recognition confidence; when it does not meet the conditions, mark the data stream to be identified as a pending protocol data stream and perform secondary recognition. S4. Based on the protocol type identifier, schedule a matching target protocol parser from the set of pluggable protocol parsers to perform deep parsing of the data stream to be identified, extract key metadata and label the asset type. S5. Combine the five-tuple information with the protocol type identifier to form a session identifier. Combine the time sliding window to reassemble data packets with the same session identifier into a bidirectional session stream. When the timeout elimination condition is met, close the corresponding session while retaining the business context semantic information. S6. Input the bidirectional session stream carrying the key metadata and asset type labels into the rule engine, perform matching processing according to the preset rule base, output the matching result, the matching content and its offset in the original data packet and store it.
2. The flow filtering and acquisition method according to claim 1, characterized in that, The construction of the multidimensional feature vector of the data stream to be identified includes: Extract the source port and destination port of the data stream to be identified, and compare them with a preset well-known port number to obtain port feature components; The packet length distribution feature component is obtained by statistically analyzing the packet length sequence, the temporal feature component is obtained by statistically analyzing the time interval sequence, and the load entropy value feature component is obtained by calculating the information entropy of the load sampling set. The uplink and downlink directional parameters are extracted to obtain directional feature components; After normalizing each feature component, they are concatenated according to their dimensions to obtain the multidimensional feature vector.
3. The flow filtering and acquisition method according to claim 1, characterized in that, The process of constructing a multidimensional feature vector for the data stream to be identified, calculating the similarity between the multidimensional feature vector and the standard feature vectors of each known protocol based on a pre-built protocol feature library, and obtaining a similarity set; when the similarity set meets a preset judgment condition, outputting the corresponding protocol type identifier and identification confidence level; when not meeting the condition, marking the data stream to be identified as a pending protocol data stream and performing secondary identification includes: For each known protocol in the protocol feature library, the sub-similarity of the multi-dimensional feature vector and the standard feature vector of the known protocol in each feature dimension is calculated, and the comprehensive similarity is obtained by weighting and fusing them according to the corresponding weight coefficients. The similarity set is obtained by traversing the protocol feature library and sorted in descending order of comprehensive similarity. When the overall similarity of the first and second ranked items is not less than the identification confidence threshold, and the difference in overall similarity between the first and second ranked items is greater than the confidence difference threshold, the known protocol corresponding to the first ranked item is determined to be the protocol type of the data stream to be identified; otherwise, it is marked as a data stream with an undetermined protocol. The weighting coefficients are dynamically adjusted based on the inter-class dispersion of each feature dimension in the protocol feature library; the greater the inter-class dispersion, the greater the weight. The recognition confidence threshold and the confidence difference threshold are dynamically adjusted based on the semantic verification accuracy of the recognition results within a preset period.
4. The flow filtering and acquisition method according to claim 3, characterized in that, The secondary identification includes; Expand the sampling window of the pending protocol data stream, increase the number of data packets participating in the statistics, and supplement at least one dimension of protocol keyword features, byte n-gram grammar fingerprint features, and transport layer security protocol handshake features to reconstruct an extended multidimensional feature vector; The extended multidimensional feature vector is re-matched with the protocol feature library for similarity; if the first and second comprehensive similarity after matching is not less than the recognition confidence threshold, the corresponding protocol type is determined. If the conditions are still not met, the deep packet inspection fingerprint database is invoked to match the payload leading byte sequence with the protocol fingerprint regular expression in the fingerprint database. If the match is successful, the corresponding protocol type is determined; if the match still fails, the data stream is marked as an unknown protocol data stream.
5. The flow filtering and acquisition method according to claim 1, characterized in that, The step of scheduling a matching target protocol parser from the set of pluggable protocol parsers according to the protocol type identifier, performing deep parsing on the data stream to be identified, extracting key metadata and labeling it with asset type includes: comparing the identification confidence with the parsing path switching threshold; if it is not less than the parsing path switching threshold, scheduling to the fast parsing path and directly extracting key metadata according to the corresponding field offset template; if it is less than the parsing path switching threshold, scheduling to the complete parsing path and performing full field parsing and semantic verification.
6. The flow filtering and acquisition method according to claim 4, characterized in that, It also includes online incremental updates of the protocol signature database and steps for discovering unknown protocols, specifically including: For identified data streams with an identification confidence level not lower than the feature library update confidence level threshold, an exponentially weighted moving average algorithm is used to incrementally update the standard feature vector of the corresponding known protocol, and the sample count is updated synchronously. The extended multidimensional feature vectors of all unknown protocol data streams are clustered to obtain several candidate protocol clusters. When the number of samples in a candidate protocol cluster is not less than a set number and the duration is not less than a set duration, it is determined to be a stable protocol cluster, and a protocol type identifier and an initial standard feature vector are generated and registered in the protocol feature library.
7. A flow filtering and acquisition system, used to perform the method as described in any one of claims 1-6, characterized in that, include: The data acquisition module is used to acquire network data packets in user space using kernel bypass mode. It distributes data packets from multiple network interface card (NIC) receive queues to the corresponding acquisition threads through the receiving end scaling hash rule to obtain the raw data packet stream. The data preprocessing module is used to parse the data link layer, network layer, and transport layer protocol headers of each data packet in the original data packet stream, extract the five-tuple information, packet length, timestamp, and payload preamble byte sequence; according to the five-tuple information, the data packets are grouped into several data streams to be identified, and the packet length sequence, time interval sequence, and payload sampling set corresponding to each data stream to be identified are generated; The protocol self-identification module is used to construct a multi-dimensional feature vector of the data stream to be identified, calculate the similarity between the multi-dimensional feature vector and the standard feature vectors of each known protocol in the protocol feature library based on a pre-built protocol feature library, and obtain a similarity set; when the similarity set meets the preset judgment conditions, the corresponding protocol type identifier and identification confidence level are output; when not, the data stream to be identified is marked as a pending protocol data stream and a secondary identification is performed. The pluggable protocol parsing module is used to schedule a matching target protocol parser from the set of pluggable protocol parsers according to the protocol type identifier, perform deep parsing on the data stream to be identified, extract key metadata, and label the asset type. The session reassembly module is used to combine the five-tuple information with the protocol type identifier to form a session identifier, and combine a time sliding window to reassemble data packets with the same session identifier into a bidirectional session stream; when the timeout elimination condition is met, the corresponding session is closed while retaining the business context semantic information. The rule filtering module is used to input the bidirectional session stream carrying the key metadata and asset type labels into the rule engine, perform matching processing according to the preset rule base, output the matching result, the matching content and its offset in the original data packet and store it.
8. The flow filtering and acquisition system according to claim 7, characterized in that, It also includes a pipeline scheduling module; The data pre-processing module, protocol self-identification module, pluggable protocol parsing module, session reassembly module, and rule filtering module are multiple loosely coupled independent processing stages, each of which is bound to different processing cores of a multi-core processor for parallel execution. Data batches are transmitted between different processing stages via asynchronous message queues; The pipeline scheduling module monitors the system load in real time and dynamically adjusts the batch processing data volume of each processing stage according to the system load: when the system load is lower than the preset load threshold, small batch processing is used to reduce processing latency; when the system load is higher than the preset load threshold, large batch processing is used to increase processing throughput.
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 traffic filtering and collection method as described in any one of claims 1-6.
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 traffic filtering and collection method as described in any one of claims 1-6.
