Network abnormal traffic detection method and device, equipment and storage medium
Through machine learning methods and relative entropy gain calculation, the characteristics of network traffic are automatically extracted, which solves the problem of low accuracy of abnormal network traffic detection in the existing technology, realizes the identification and adaptation of new attacks, and reduces the complexity and complexity of feature extraction. Human resource needs.
Patent Information
- Application Number
- CN202410962687.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-18
- Publication Date
- 2024-09-20
AI Technical Summary
Existing network abnormal traffic detection methods have low accuracy, threshold-based methods are difficult to adapt to different business types and network sizes, feature matching methods are not adaptable to new attacks, and rely on a large number of human resources to maintain feature libraries.
Using a method based on machine learning, by obtaining the network layer and transport layer header data of network traffic data packets, using the target feature function set and the preset network abnormal traffic detection model, the relative entropy gain is calculated to determine the traffic status, and the best value is automatically extracted and learned. Useful features adapt to dynamic changes in network traffic, reducing feature extraction complexity and dependence on business knowledge.
It improves the accuracy of abnormal traffic detection, reduces false positives and false negatives, has strong anti-interference capabilities and generalization capabilities, and can identify unknown abnormal traffic without prior knowledge of attack patterns.
Smart Images

Figure CN118677693A
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method, device, equipment and storage medium for detecting abnormal network traffic. Background Art
[0002] With the rapid development of technologies such as the Internet, mobile Internet, and the Internet of Things, a large amount of data is generated, and data security issues are becoming increasingly prominent. With the continuous enhancement and evolution of network attacks, many of the attackers' attack behaviors, including live host detection, port scanning, slow attacks, botnets, vulnerability scanning, etc., may cause fluctuations in network traffic. Therefore, by detecting the fluctuation of network traffic, it is possible to effectively monitor the changes in abnormal traffic in the network and thus discover network attack activities.
[0003] In the related art, when performing abnormal network traffic detection, threshold-based methods and feature matching-based methods are usually used. Specifically, the threshold-based method is to determine whether the actual traffic exceeds the threshold by setting the traffic threshold, so as to determine whether it is abnormal traffic; the feature matching-based method is to match abnormal behaviors in the traffic by maintaining a large number of feature libraries, and then determine whether it is abnormal traffic.
[0004] However, there is a problem of low accuracy when using the above methods to detect abnormal network traffic. Summary of the invention
[0005] The present application aims to at least solve the technical problems existing in the prior art. To this end, the first aspect of the present application proposes a method for detecting abnormal network traffic, the method comprising: Acquire a plurality of current network traffic data packets within a first preset time period; wherein the current network traffic data packets include packet header data of a network layer and a transport layer of a target network; For the current network traffic data packets within each first preset time period, the packet header data is processed by using the target feature function set and the preset network abnormal traffic detection model to generate a processing result; Based on the target relative entropy gain between the processing result and the preset model empirical distribution, the flow state information corresponding to the current network flow data packet is determined; wherein the flow state information includes abnormal flow state and normal flow state.
[0006] In a possible implementation, based on the target relative entropy gain between the processing result and the preset model empirical distribution, determining the flow state information corresponding to the current network flow data packet includes: Calculate the target relative entropy gain between the processing result and the preset model empirical distribution; If the duration of the target relative entropy gain exceeding the first preset threshold is greater than or equal to the first preset time period, determining that the flow state information corresponding to the current network flow data packet is an abnormal flow state; If the duration that the target relative entropy gain exceeds the first preset threshold is less than the first preset time period, it is determined that the traffic state information corresponding to the current network traffic data packet is a normal traffic state.
[0007] In a possible implementation, the generation process of the preset model experience distribution includes: Acquire a training data set; wherein the training data set includes a plurality of historical network traffic data packets within a second preset time period under a normal business state of the target network; Classify multiple historical network traffic data packets in the training data set to obtain at least one first classification result, and calculate a first weight corresponding to each first classification result; wherein the first weight is used to characterize the proportion of the number of historical network traffic data packets of each first classification result in the total first classification result; Based on the candidate feature function set and the number of classifications corresponding to the total first classification result, the preset model empirical distribution corresponding to the training data set is calculated.
[0008] In a possible implementation, the process of building a preset network abnormal traffic detection model includes: Calculate the initial model distribution based on the total number of preset data packet classifications; Traversing each candidate feature function in the candidate feature function set in turn, adding the currently traversed candidate feature function to the intermediate feature function set, and obtaining an updated feature function set; Based on the updated feature function set, multiple historical network traffic data packets in the training data set are classified to obtain at least one second classification result, and a second weight corresponding to each second classification result is calculated; wherein the second weight is used to characterize the proportion of the number of historical network traffic data packets of each second classification result in the total second classification result; Based on the initial model distribution, the updated feature function set and the second weight, calculating the current model distribution corresponding to the training data set; Calculate the current relative entropy gain between the current model distribution and the preset model empirical distribution, and continue to update the intermediate feature function set based on the current relative entropy gain to generate the target feature function set and the preset network abnormal traffic detection model.
[0009] In a possible implementation, the intermediate feature function set is continuously updated based on the current relative entropy gain to generate a target feature function set, including: Comparing the current relative entropy gain with a second preset threshold value to generate a comparison result; If the comparison result does not meet the preset conditions, the candidate feature function corresponding to the current relative entropy gain is removed from the intermediate feature function set, and other candidate feature functions in the candidate feature function set are traversed in sequence, and the above steps of continuing to update the intermediate feature function set based on the current relative entropy gain are repeated; If the comparison result meets the preset conditions, the candidate feature function corresponding to the current relative entropy gain is retained in the intermediate feature function set, and other candidate feature functions in the candidate feature function set are traversed in sequence, and the above steps of continuing to update the intermediate feature function set based on the current relative entropy gain are repeated; The intermediate feature function set that meets the preset update cutoff condition is used as the target feature function set.
[0010] In a possible implementation, the method further includes: Based on the current relative entropy gain, the intermediate feature function set is continuously updated to generate an intermediate network abnormal traffic detection model; After processing the intermediate network abnormal traffic detection model using a test data set and a verification data set, a preset network abnormal traffic detection model is generated; wherein the test data set and the verification data set include multiple historical network traffic data packets within a third preset time period of the target network under an abnormal business state, and the third preset time period is less than the second preset time period.
[0011] In a possible implementation, the method further includes: Acquire multiple classification label information; wherein the classification label information includes network layer protocol type, transport layer protocol type, destination port and TCP flag; Based on the multiple classification label information, the total number of preset data packet classifications is obtained.
[0012] The second aspect of the present application provides a network abnormal traffic detection device, which includes: An acquisition module, used to acquire current network traffic data packets within a plurality of first preset time periods; wherein the current network traffic data packets include packet header data of a network layer and a transport layer of a target network; A processing module, for processing the packet header data of the current network traffic data packets within each first preset time period through a target feature function set and a preset network abnormal traffic detection model to generate a processing result; A determination module is used to determine the flow state information corresponding to the current network flow data packet based on the target relative entropy gain between the processing result and the preset model experience distribution; wherein the flow state information includes abnormal flow state and normal flow state.
[0013] In a possible implementation manner, the above-mentioned determination module is specifically used to: Based on the target relative entropy gain between the processing result and the preset model empirical distribution, the traffic state information corresponding to the current network traffic data packet is determined, including: Calculate the target relative entropy gain between the processing result and the preset model empirical distribution; If the duration of the target relative entropy gain exceeding the first preset threshold is greater than or equal to the first preset time period, determining that the flow state information corresponding to the current network flow data packet is an abnormal flow state; If the duration that the target relative entropy gain exceeds the first preset threshold is less than the first preset time period, it is determined that the traffic state information corresponding to the current network traffic data packet is a normal traffic state.
[0014] In a possible implementation manner, the above-mentioned network abnormal traffic detection device is further used for: Acquire a training data set; wherein the training data set includes a plurality of historical network traffic data packets within a second preset time period under a normal business state of the target network; Classify multiple historical network traffic data packets in the training data set to obtain at least one first classification result, and calculate a first weight corresponding to each first classification result; wherein the first weight is used to characterize the proportion of the number of historical network traffic data packets of each first classification result in the total first classification result; Based on the candidate feature function set and the number of classifications corresponding to the total first classification result, the preset model empirical distribution corresponding to the training data set is calculated.
[0015] In a possible implementation manner, the above-mentioned network abnormal traffic detection device is further used for: Calculate the initial model distribution based on the total number of preset data packet classifications; Traversing each candidate feature function in the candidate feature function set in turn, adding the currently traversed candidate feature function to the intermediate feature function set, and obtaining an updated feature function set; Based on the updated feature function set, multiple historical network traffic data packets in the training data set are classified to obtain at least one second classification result, and a second weight corresponding to each second classification result is calculated; wherein the second weight is used to characterize the proportion of the number of historical network traffic data packets of each second classification result in the total second classification result; Based on the initial model distribution, the updated feature function set and the second weight, calculating the current model distribution corresponding to the training data set; Calculate the current relative entropy gain between the current model distribution and the preset model empirical distribution, and continue to update the intermediate feature function set based on the current relative entropy gain to generate the target feature function set and the preset network abnormal traffic detection model.
[0016] In a possible implementation manner, the above-mentioned network abnormal traffic detection device is further used for: Comparing the current relative entropy gain with a second preset threshold value to generate a comparison result; If the comparison result does not meet the preset conditions, the candidate feature function corresponding to the current relative entropy gain is removed from the intermediate feature function set, and other candidate feature functions in the candidate feature function set are traversed in sequence, and the above steps of continuing to update the intermediate feature function set based on the current relative entropy gain are repeated; If the comparison result meets the preset conditions, the candidate feature function corresponding to the current relative entropy gain is retained in the intermediate feature function set, and other candidate feature functions in the candidate feature function set are traversed in sequence, and the above steps of continuing to update the intermediate feature function set based on the current relative entropy gain are repeated; The intermediate feature function set that meets the preset update cutoff condition is used as the target feature function set.
[0017] In a possible implementation manner, the above-mentioned network abnormal traffic detection device is further used for: Based on the current relative entropy gain, the intermediate feature function set is continuously updated to generate an intermediate network abnormal traffic detection model; After processing the intermediate network abnormal traffic detection model using a test data set and a verification data set, a preset network abnormal traffic detection model is generated; wherein the test data set and the verification data set include multiple historical network traffic data packets within a third preset time period of the target network under an abnormal business state, and the third preset time period is less than the second preset time period.
[0018] In a possible implementation manner, the above-mentioned network abnormal traffic detection device is further used for: Acquire multiple classification label information; wherein the classification label information includes network layer protocol type, transport layer protocol type, destination port and TCP flag; Based on the multiple classification label information, the total number of preset data packet classifications is obtained.
[0019] The third aspect of the present application proposes an electronic device, which includes a processor and a memory, wherein the memory stores at least one instruction, at least one program, a code set or an instruction set, and the at least one instruction, the at least one program, the code set or the instruction set is loaded and executed by the processor to implement the network abnormal traffic detection method as described in the first aspect.
[0020] The fourth aspect of the present application proposes a computer-readable storage medium, which stores at least one instruction, at least one program, a code set or an instruction set. The at least one instruction, the at least one program, the code set or the instruction set is loaded and executed by a processor to implement the network abnormal traffic detection method as described in the first aspect.
[0021] The embodiments of the present application have the following beneficial effects: The network abnormal traffic detection method provided by the embodiment of the present application includes: obtaining current network traffic data packets within multiple first preset time periods, wherein the current network traffic data packets include packet header data of the network layer and the transport layer of the target network, for the current network traffic data packets within each first preset time period, processing the packet header data through a target feature function set and a preset network abnormal traffic detection model to generate a processing result, and determining the traffic state information corresponding to the current network traffic data packet based on the processing result and the target relative entropy gain between the empirical distribution of the preset model, wherein the traffic state information includes an abnormal traffic state and a normal traffic state. This scheme uses a machine learning-based method to obtain a preset network abnormal traffic detection model that can automatically extract and learn the most useful features from the original traffic data, reducing the complexity of feature extraction and dependence on business knowledge; and can learn general rules through training data, adapt to the dynamic changes of network traffic, and have a certain ability to identify unknown abnormal traffic; at the same time, based on statistical methods and machine learning models, it has a very strong anti-interference ability, can improve the accuracy of abnormal traffic detection, and reduce false positives and missed reports; in addition, the method of detecting abnormal traffic based on statistical theory relies on actual network traffic data, and can identify anomalies based on the statistical characteristics of historical data or real-time data, without the need for prior knowledge of attack patterns, and has a strong generalization ability. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] Figure 1 A block diagram of a computer device provided in an embodiment of the present application; Figure 2 A flowchart of the steps of the network abnormal traffic detection method provided in the embodiment of the present application; Figure 3 A flowchart of the steps of data packet classification provided in an embodiment of the present application; Figure 4 A flowchart of the steps of constructing a preset network abnormal traffic detection model provided in an embodiment of the present application; Figure 5 A flowchart of the steps for generating a preset model empirical distribution provided in an embodiment of the present application; Figure 6 A flowchart of the steps for generating a target feature function set provided in an embodiment of the present application; Figure 7 Another flow chart of steps for generating a preset network abnormal traffic detection model provided in an embodiment of the present application; Figure 8 A flow chart of the steps for determining flow status information provided in an embodiment of the present application; Fig. 9 An overall flow chart of building a preset network abnormal traffic detection model provided in an embodiment of the present application; Fig.10 An overall flow chart of model testing and verification provided for an embodiment of the present application; Fig.11 A structural block diagram of a network abnormal traffic detection device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0023] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0024] With the rapid development of technologies such as the Internet, mobile Internet, and the Internet of Things, a large amount of data is generated, and data security issues are becoming increasingly prominent. With the continuous enhancement and evolution of network attacks, many of the attackers' attack behaviors, including live host detection, port scanning, slow attacks, botnets, vulnerability scanning, etc., may cause fluctuations in network traffic. Therefore, by detecting the fluctuation of network traffic, it is possible to effectively monitor the changes in abnormal traffic in the network and thus discover network attack activities.
[0025] In the related art, when performing abnormal network traffic detection, threshold-based methods and feature matching-based methods are usually used. Specifically, the threshold-based method is to determine whether the actual traffic exceeds the threshold by setting the traffic threshold, so as to determine whether it is abnormal traffic; the feature matching-based method is to match abnormal behaviors in the traffic by maintaining a large number of feature libraries, and then determine whether it is abnormal traffic. However, these methods have the following problems in detecting abnormal traffic: 1. For the threshold-based method, it is difficult to select a suitable threshold. The threshold is highly dependent on the specific business type, network scale, time period, etc. Different scenarios require different thresholds to improve the accuracy of detection.
[0026] 2. The threshold-based method has a weak fault tolerance capability. Setting the threshold too high may cause abnormal traffic to be missed, while setting it too low may cause an increase in false alarms.
[0027] 3. The accuracy of the feature matching method depends on the feature rule base, so it is necessary to continuously collect, maintain and update the rule base, which consumes a lot of human resources.
[0028] 4. The feature matching-based method is not adaptable enough to new attacks. The detection features designed for known attack patterns may not be able to effectively identify new or unknown attacks, especially those carefully designed to evade detection.
[0029] Since the above-mentioned traditional security defense measures such as firewalls and intrusion detection systems can often only identify known attack patterns and are difficult to deal with new and unknown attacks, more intelligent and flexible abnormal traffic detection technology is needed to deal with increasingly complex network security threats.
[0030] With the development of big data and machine learning technology, its powerful data-driven, nonlinear modeling and self-learning capabilities provide a new perspective and tools for abnormal traffic detection. Users can better process and analyze massive amounts of network data and mine potential attack features and patterns from them. Machine learning-based abnormal traffic detection technology can learn and identify abnormal traffic patterns by analyzing historical data, thereby greatly improving the accuracy and efficiency of detection. In addition, abnormal traffic detection technology is also affected by multiple factors such as compliance and regulatory requirements. These factors jointly promote the continuous innovation and evolution of abnormal traffic detection technology to adapt to the increasingly severe network security situation and complex network environment requirements.
[0031] In view of this, the present application proposes a network abnormal traffic detection method, device, equipment and storage medium, the method comprising: obtaining current network traffic data packets within multiple first preset time periods, wherein the current network traffic data packets include packet header data of the network layer and the transport layer of the target network, for the current network traffic data packets within each first preset time period, processing the packet header data through a target feature function set and a preset network abnormal traffic detection model to generate a processing result, and determining the traffic state information corresponding to the current network traffic data packet based on the processing result and the target relative entropy gain between the empirical distribution of the preset model, wherein the traffic state information includes an abnormal traffic state and a normal traffic state. This scheme uses a machine learning-based method to obtain a preset network abnormal traffic detection model that can automatically extract and learn the most useful features from the original traffic data, reducing the complexity of feature extraction and dependence on business knowledge; and can learn general rules through training data, adapt to the dynamic changes of network traffic, and have a certain ability to identify unknown abnormal traffic; at the same time, based on statistical methods and machine learning models, it has a very strong anti-interference ability, can improve the accuracy of abnormal traffic detection, and reduce false positives and missed reports; in addition, the method of detecting abnormal traffic based on statistical theory relies on actual network traffic data, and can identify anomalies based on the statistical characteristics of historical data or real-time data, without the need for prior knowledge of attack patterns, and has a strong generalization ability.
[0032] In the following, the terms "first" and "second" are used for descriptive purposes only and are not to be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, features defined as "first" and "second" may explicitly or implicitly include one or more of the features. In the description of the embodiments of the present disclosure, unless otherwise specified, "multiple" means two or more. In addition, the use of "based on" or "according to" means openness and inclusiveness, because the process, steps, calculations or other actions "based on" or "according to" one or more of the conditions or values may be based on additional conditions or values beyond the described values in practice.
[0033] The network abnormal traffic detection method provided in the present application can be applied to computer devices (electronic devices), and the computer device can be a server or a terminal, wherein the server can be a single server or a server cluster composed of multiple servers. The embodiments of the present application do not make specific limitations on this. The terminal can be but is not limited to various personal computers, laptops, smart phones, tablet computers and portable wearable devices.
[0034] Take the computer device as a server as an example. Figure 1 A block diagram of a server is shown, such as Figure 1As shown, the server may include a processor and a memory connected via a system bus. The processor of the server is used to provide computing and control capabilities. The memory of the server includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. When the computer program is executed by the processor, a method for detecting abnormal network traffic is implemented.
[0035] Those skilled in the art will understand that Figure 1 The structure shown in the figure is only a block diagram of a partial structure related to the solution of the present application, and does not constitute a limitation on the server to which the solution of the present application is applied. Optionally, the server may include more or fewer components than shown in the figure, or combine certain components, or have a different arrangement of components.
[0036] It should be noted that the execution subject of the embodiments of the present application may be a computer device or a network abnormal traffic detection device. The following method embodiments are described using a computer device as the execution subject.
[0037] Figure 2 The following is a flowchart of the method for detecting abnormal network traffic provided by the embodiment of the present application. Figure 2 As shown, the method comprises the following steps: Step 202: Obtain current network traffic data packets within a plurality of first preset time periods.
[0038] The current network traffic data packet includes header data of the network layer and transport layer of the target network. The header data may be divided according to a time interval of 1 second, and the first preset time period indicates the duration of the divided data, for example, 60 seconds.
[0039] Therefore, when performing abnormal network traffic detection, current network traffic data packets within a plurality of first preset time periods can be obtained first. Optionally, the computer device can obtain the current network traffic data packets in real time.
[0040] Step 204: for the current network traffic data packets within each first preset time period, the packet header data is processed by using the target feature function set and the preset network abnormal traffic detection model to generate a processing result.
[0041] The target feature function set is the optimal feature function set obtained after the preset network abnormal traffic detection model is trained. The preset network abnormal traffic detection model is a model pre-trained by a training data set corresponding to a plurality of historical network traffic data packets.
[0042] When building a preset network abnormal traffic detection model, you need to first classify the data packets, such as Figure 3 As shown, Figure 3 A flowchart of the steps of data packet classification provided in an embodiment of the present application includes: Step 302: Obtain multiple classification label information.
[0043] Step 304: Based on the multiple classification label information, the total number of preset data packet classifications is obtained.
[0044] The classification label information may include the network layer protocol type, the transport layer protocol type, the destination port and the TCP flag. Of course, other types of classification label information may also be included, for example, other field information in the packet header data, load information, etc., as long as the classification effect can be achieved, and the embodiments of the present application do not specifically limit this.
[0045] In some optional embodiments, the data packets may be classified into multiple categories according to the two dimensions of protocol and destination port. The specific classification method is as follows: 1. Divide the data packets into three categories according to TCP protocol, UDP protocol, and ICMP protocol. TCP protocol and UDP protocol account for a relatively high proportion of network traffic and are relatively important; host detection and other behaviors will generate a large number of ICMP packets. For example, the characteristic function corresponding to the TCP protocol is It is defined as the form shown in formula (1), where the value is 1 if the condition is met, and 0 otherwise. The characteristic functions of the UDP protocol and ICMP protocol are similar to those of the TCP protocol, so they are not explained one by one here.
[0046] (1) 2. The data packets whose protocol is TCP are divided into two categories according to the TCP flags, that is, whether the TCP flag contains SYN or RST. Among them, SYN is the flag when the connection is established. SYN flood attacks or port scanning will cause a large number of SYN packets; RST flag is the flag when the connection is rejected or reset. Scanning non-existent ports will cause a large number of RST packets. For example, the TCP flag contains the characteristic function corresponding to SYN It is defined as the form shown in formula (2), where the value is 1 if the condition is met, otherwise it is 0. The characteristic function corresponding to the RST in the TCP flag is similar to formula (2).
[0047] (2) 3. Data packets with TCP and UDP protocols are further divided into 588 categories according to the destination port. Optionally, because the proportion of WEB traffic is usually relatively large, ports 80 and 443 are used as two independent categories; 10 well-known ports with destination ports of 0-1023, i.e., those assigned by the Internet Assigned Numbers Authority (IANA), are divided into one category for every 10, for a total of 103 categories; registered ports with destination ports of 1024-49151 are divided into one category for every 100, for a total of 482 categories; dynamically used ports or private ports with destination ports of 49152-65535 are divided into one category. For example, the characteristic function of the destination port of 80 It is defined as shown in formula (3), where the value is 1 if the condition is met, otherwise it is 0. The characteristic functions corresponding to other ports or port ranges are similar to formula (3).
[0048] (3) Therefore, according to the two dimensions of protocol and destination port, the data packets can be divided into 1765 categories in total, namely TCP protocol: categories, UDP protocol: 588 categories, ICMP protocol: 1 category, a total of 1765 categories, 1756 is the total number of preset data packet categories.
[0049] These packet classes form the common domain for data packet classification , according to the preset packet classification, the distribution of different packets in normal traffic is estimated, and it is used as the baseline distribution for detecting network traffic anomalies; all feature functions constitute the candidate feature function set It should be noted that Both represent data packets. f All represent characteristic functions, and data packets correspond to characteristic functions one by one, for example correspond f 1.
[0050] After the data packets are classified, the model training, testing and verification process can be carried out through the collected data sets. Among them, the data collection and labeling process can be carried out first. Optionally, it can include collecting multiple historical network traffic data packets in the second preset time period under the normal business state of the target network as the training data set. . At the same time, it is necessary to collect multiple historical network traffic data packets within the third preset time period under the abnormal business state of the target network, and manually analyze and mark the abnormal traffic in it as a test data set and a verification data set. Among them, the third preset time period is smaller than the second preset time period. Exemplarily, the second preset time period can be within one week, and the third time period can be three days. In addition, the normal business state is the case when no attack behavior occurs, and the abnormal business state is the opposite of the normal business state.
[0051] Then, the feature function selection and model construction can be performed, wherein the feature selection uses a greedy algorithm, which selects the optimal feature function from the above-mentioned candidate feature function set to minimize the difference between the current model distribution and the preset model empirical distribution. In addition, the present application uses the KL divergence algorithm to calculate the relative entropy gain, i.e., the difference, between the two model distributions. Of course, other algorithms, such as JS divergence, Hellinger distance, etc., can also be used to calculate the difference, which is not specifically limited in the present application embodiment.
[0052] Among them, KL divergence, also known as relative entropy, is a statistic that measures the difference between two probability distributions. It is mainly used to quantify the degree of mismatch between one probability distribution (usually regarded as the "true" distribution or reference distribution) and another probability distribution (usually regarded as the "fitted" or "estimated" distribution).
[0053] Alternatively, if Figure 4 As shown, Figure 4 A flowchart of the steps of building a preset network abnormal traffic detection model provided in an embodiment of the present application includes: Step 402: Calculate the initial model distribution based on the total number of preset data packet categories.
[0054] Step 404: traverse each candidate feature function in the candidate feature function set in turn, add the currently traversed candidate feature function to the intermediate feature function set, and obtain an updated feature function set.
[0055] Step 406: classify multiple historical network traffic data packets in the training data set based on the updated feature function set to obtain at least one second classification result, and calculate the second weight corresponding to each second classification result.
[0056] Step 408: Calculate the current model distribution corresponding to the training data set based on the initial model distribution, the updated feature function set and the second weight.
[0057] Step 410: Calculate the current relative entropy gain between the current model distribution and the preset model empirical distribution, and continue to update the intermediate feature function set based on the current relative entropy gain to generate a target feature function set and a preset network abnormal traffic detection model.
[0058] Among them, Figure 5 As shown, Figure 5 A flowchart of the steps of generating a preset model empirical distribution provided in an embodiment of the present application includes: Step 502: Obtain a training data set.
[0059] Step 504: classify multiple historical network traffic data packets in the training data set to obtain at least one first classification result, and calculate a first weight corresponding to each first classification result.
[0060] Step 506: Calculate the preset model empirical distribution corresponding to the training data set based on the candidate feature function set and the number of classifications corresponding to the total first classification result.
[0061] Among them, the empirical distribution model refers to a probability distribution model directly constructed based on actual observed data. This model does not rely on any specific distribution family assumptions, but is completely determined by the data itself. Therefore, it is a data-driven non-parametric method. The empirical distribution model is mainly used to describe the distribution characteristics of the data, perform statistical inference, and serve as an approximation of the data generation process in subsequent analysis. The core component of the empirical distribution model is the empirical distribution function, which is directly constructed based on sample data and is an unbiased estimate of the overall distribution of the data. It is particularly suitable for situations where there is a lack of prior knowledge or assumptions about the data distribution. This application is based on this idea to calculate the preset model empirical distribution corresponding to the training data set.
[0062] The training data set includes multiple historical network traffic data packets of the target network in a second preset time period under normal business conditions. The multiple historical network traffic data packets in the training data set can be classified according to the data packet classification method provided in the above embodiment, so as to obtain at least one first classification result, and calculate the first weight corresponding to each first classification result The first weight is used to represent the proportion of each first classification result in the number of historical network traffic data packets in the total first classification result.
[0063] Based on the candidate feature function set and the number of classifications corresponding to the total first classification results, the preset model empirical distribution corresponding to the training data set is calculated by formula (4). Among them, the candidate feature function set is F, and the formula (4) f That is the candidate feature function in F.
[0064] (4) in, is the empirical distribution of the preset model; x i are historical network traffic packets in the training dataset; n is the number of categories corresponding to the total first classification results.
[0065] Next, the initial model distribution can be calculated using formula (5) based on the total number of preset data packet classifications.
[0066] (5) in, is the initial model distribution; if the preset data packet classification provided in the above embodiment is adopted, Z here is 1765.
[0067] Then, the candidate feature functions in the candidate feature function set are traversed in turn, and the currently traversed candidate feature function is added to the intermediate feature function set to obtain an updated feature function set. The intermediate feature function set is empty at the beginning.
[0068] Next, multiple historical network traffic data packets in the training data set can be classified based on the updated feature function set to obtain at least one second classification result, and the second weight corresponding to each second classification result can be calculated. The second weight is used to characterize the proportion of each second classification result in the number of historical network traffic data packets in the total second classification result. Based on the initial model distribution, the updated feature function set and the second weight, the current model distribution corresponding to the training data set is calculated by formula (6).
[0069] (6) in, is the current model distribution; is the second weight; is the characteristic function corresponding to each second classification result; i is the total number of second classification results.
[0070] Finally, the current relative entropy gain between the current model distribution and the preset model empirical distribution can be calculated, and the intermediate feature function set can be continued to be updated based on the current relative entropy gain to generate the target feature function set and the preset network abnormal traffic detection model.
[0071] Among them, when generating the target feature function set, such as Figure 6 As shown, Figure 6 A flowchart of the steps of generating a target feature function set provided in an embodiment of the present application includes: Step 602: Compare the current relative entropy gain with a second preset threshold to generate a comparison result.
[0072] Step 604: If the comparison result does not meet the preset conditions, the candidate feature function corresponding to the current relative entropy gain is removed from the intermediate feature function set, and other candidate feature functions in the candidate feature function set are traversed in sequence, and the above steps of continuing to update the intermediate feature function set based on the current relative entropy gain are repeated.
[0073] Step 606: If the comparison result meets the preset conditions, the candidate feature function corresponding to the current relative entropy gain is retained in the intermediate feature function set, and other candidate feature functions in the candidate feature function set are traversed in sequence, and the above steps of continuing to update the intermediate feature function set based on the current relative entropy gain are repeated.
[0074] Step 608: taking the intermediate feature function set that meets the preset update cutoff condition as the target feature function set.
[0075] Optionally, the KL divergence algorithm can be used to calculate the current model distribution Empirical distribution with preset model The current relative entropy gain between Indicates that the larger the current relative entropy gain is, the greater the influence of the current candidate feature function on the model is.
[0076] Thus, the current relative entropy gain can be compared with the second preset threshold to generate a comparison result, and the second preset threshold can be pre-customized. If the comparison result does not meet the preset condition, the candidate feature function corresponding to the current relative entropy gain is removed from the intermediate feature function set and other candidate feature functions in the candidate feature function set are traversed in sequence, and the above-mentioned step of continuing to update the intermediate feature function set based on the current relative entropy gain is repeated. Among them, the preset condition can be that the absolute value of the difference between the current relative entropy gain and the second preset threshold is greater than a preset value.
[0077] If the comparison result meets the preset conditions, the candidate feature function corresponding to the current relative entropy gain will be retained in the intermediate feature function set, and other candidate feature functions in the candidate feature function set will be traversed in turn, and the above steps of continuing to update the intermediate feature function set based on the current relative entropy gain will be repeated.
[0078] For example, during the first execution, the candidate feature function set is first f 1 is added to the intermediate feature function set, and after the above comparison and judgment process, it is determined whether it needs to be retained or removed f 1. If you keep f 1, then the updated feature function set includes f 1. Then, the candidate feature function set f2 Add it to the intermediate feature function set, and after the above comparison and judgment process, determine whether it needs to be retained or removed f 2. If you keep f 2, then the updated feature function set includes f 1 and f 2.
[0079] For example, during the first execution, the candidate feature function set will be f 1 is added to the intermediate feature function set, and after the above comparison and judgment process, it is determined whether it needs to be retained or removed f 1. If removed f 1, the updated feature function set is still empty. Then, f 2 Add it to the intermediate feature function set, and after the above comparison and judgment process, determine whether it needs to be retained or removed f 2. If you keep f 2, then the updated feature function set only includes f 2.
[0080] Finally, the intermediate feature function set that meets the preset update cutoff condition is used as the target feature function set. The preset update cutoff condition can be to traverse all candidate feature functions, or to reach the number of candidate feature function selections, which can be pre-defined, so that it is not necessary to traverse all candidate feature functions, which can improve the efficiency of model training.
[0081] The target feature function set saved in the above process is used as the final selected feature function set, and the current model distribution finally obtained is used as the preset network abnormal traffic detection model for subsequent testing and actual abnormal traffic detection.
[0082] In some optional embodiments, the model can also be tested, verified, and tuned using a test data set and a validation data set, such as Figure 7 As shown, Figure 7 Another step flow chart for generating a preset network abnormal traffic detection model provided in an embodiment of the present application includes: Step 702: Continue to update the intermediate feature function set based on the current relative entropy gain to generate an intermediate network abnormal traffic detection model.
[0083] Step 704: After processing the intermediate network abnormal traffic detection model using the test data set and the verification data set, a preset network abnormal traffic detection model is generated.
[0084] The test data set and the verification data set include a plurality of historical network traffic data packets within a third preset time period under an abnormal service state of the target network.
[0085] The model parameters may be preset, and the model parameters may include a time interval t of 1 second, a duration d of 60 seconds, a relative entropy gain g of 0.01, and a gain multiple m of 30. Then, the test data set may be segmented according to the time interval, and the intermediate feature function set may be continuously updated based on the current relative entropy gain to generate an intermediate network abnormal traffic detection model. In addition, the test data set within each duration may be predicted based on the target feature function set and the intermediate network abnormal traffic detection model.
[0086] Next, the prediction results of the test data set within the current duration and the preset model experience distribution under normal business conditions can be calculated The current relative entropy gain between . You can also use a two-dimensional graph to statistically analyze the change in the current relative entropy gain of the test data set over time, where the horizontal axis is time and the vertical axis is the corresponding current relative entropy gain in the time period.
[0087] According to the set model parameters, count whether the current relative entropy gain exceeds 0.3 for 60 consecutive seconds in the two-dimensional graph (i.e. ). If this happens, it means that these flows are abnormal flows, otherwise, they are normal flows. Finally, the model prediction results and the manually marked results can be compared to verify whether the model prediction is accurate. If it is inaccurate, analyze the reasons, adjust the model parameters, and test the model results again until the accuracy of the model prediction reaches the expected level. Finally, save the adjusted model parameters to generate the final preset network abnormal traffic detection model. Among them, the statistical parameters can be dynamically adjusted according to the changes in network traffic, such as updating the baseline model, adapting to the periodic changes in traffic, etc. This can adapt to the dynamic changes of the network environment to a certain extent and is more in line with the actual network traffic characteristics.
[0088] In addition, the present application uses the maximum entropy estimation algorithm to train the model. Of course, other statistical algorithms or machine learning algorithms, such as XGBoost, CNN, random forest, etc., can also be used to train the model. The embodiments of the present application do not specifically limit this. Among them, the maximum entropy estimation algorithm is a statistical inference method for estimating a probability distribution model based on known constraints. This method follows the maximum entropy principle, that is, on the premise of satisfying all known information or constraints, the distribution with maximum entropy is selected as the optimal estimate. The core idea of the maximum entropy principle is to seek a balance between the quantification of uncertainty (entropy) and the true response of known data (constraints), so that the model fully respects the information provided by the known data while maintaining the maximum uncertainty of unknown information (i.e., the least biased).
[0089] Step 206: Determine the flow state information corresponding to the current network flow data packet based on the target relative entropy gain between the processing result and the preset model empirical distribution.
[0090] The flow state information includes abnormal flow state and normal flow state. In some optional embodiments, such as Figure 8 As shown, Figure 8 A flowchart of the steps of determining flow status information provided in an embodiment of the present application includes: Step 802: Calculate the target relative entropy gain between the processing result and the preset model empirical distribution.
[0091] Step 804: If the duration that the target relative entropy gain exceeds the first preset threshold is greater than or equal to the first preset time period, it is determined that the traffic state information corresponding to the current network traffic data packet is an abnormal traffic state.
[0092] Step 806: If the duration that the target relative entropy gain exceeds the first preset threshold is less than the first preset time period, it is determined that the traffic state information corresponding to the current network traffic data packet is a normal traffic state.
[0093] Among them, similar to the above-mentioned model testing and verification process, the processing result of the preset network abnormal traffic detection model on the current network traffic data packet and the preset model experience distribution can be calculated If the duration of the target relative entropy gain exceeding the first preset threshold is greater than or equal to the first preset time period, the flow state information corresponding to the current network flow data packet is determined to be an abnormal flow state; if the duration of the target relative entropy gain exceeding the first preset threshold is less than the first preset time period, the flow state information corresponding to the current network flow data packet is determined to be a normal flow state.
[0094] The first preset threshold value may be a preset gain multiple of the preset relative entropy gain. For example, the preset relative entropy gain may be 0.01, and the preset gain multiple may be 30. Thus, the first preset threshold value may be set to 0.3, that is, The first preset time period may be 60 seconds.
[0095] In some optional embodiments, when it is determined that the current network traffic data packet is in an abnormal traffic state, a production alarm notification may be issued for the detected abnormal traffic to notify the system administrator to handle it.
[0096] The network abnormal traffic detection method provided by the embodiment of the present application includes: obtaining current network traffic data packets within multiple first preset time periods, wherein the current network traffic data packets include packet header data of the network layer and the transport layer of the target network, for the current network traffic data packets within each first preset time period, processing the packet header data through a target feature function set and a preset network abnormal traffic detection model to generate a processing result, and determining the traffic state information corresponding to the current network traffic data packet based on the processing result and the target relative entropy gain between the empirical distribution of the preset model, wherein the traffic state information includes an abnormal traffic state and a normal traffic state. This scheme uses a machine learning-based method to obtain a preset network abnormal traffic detection model that can automatically extract and learn the most useful features from the original traffic data, reducing the complexity of feature extraction and dependence on business knowledge; and can learn general rules through training data, adapt to the dynamic changes of network traffic, and have a certain ability to identify unknown abnormal traffic; at the same time, based on statistical methods and machine learning models, it has a very strong anti-interference ability, can improve the accuracy of abnormal traffic detection, and reduce false positives and missed reports; in addition, the method of detecting abnormal traffic based on statistical theory relies on actual network traffic data, and can identify anomalies based on the statistical characteristics of historical data or real-time data, without the need for prior knowledge of attack patterns, and has a strong generalization ability.
[0097] in addition, Fig. 9 The present invention provides an overall flow chart for constructing a preset network abnormal traffic detection model. Fig.10 An overall flow chart of model testing and verification provided in an embodiment of the present application.
[0098] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0099] Fig.11 A structural block diagram of a network abnormal traffic detection device provided in an embodiment of the present application.
[0100] like Fig.11 As shown, the network abnormal traffic detection device 1100 includes: The acquisition module 1102 is used to acquire current network traffic data packets within multiple first preset time periods; wherein the current network traffic data packets include packet header data of the network layer and the transport layer of the target network.
[0101] The processing module 1104 is used to process the packet header data of the current network traffic data packets within each first preset time period through a target feature function set and a preset network abnormal traffic detection model to generate a processing result.
[0102] Determination module 1106 is used to determine the flow state information corresponding to the current network flow data packet based on the target relative entropy gain between the processing result and the preset model empirical distribution; wherein the flow state information includes abnormal flow state and normal flow state.
[0103] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here. Each module in the above network abnormal traffic detection device can be implemented in whole or in part by software, hardware and a combination thereof. The above modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory in the computer device in the form of software, so that the processor can call and execute the operations of the above modules.
[0104] In one embodiment of the present application, a computer device is provided, the computer device comprising a memory and a processor, the memory storing a computer program, and the processor implementing the following steps when executing the computer program: Acquire a plurality of current network traffic data packets within a first preset time period; wherein the current network traffic data packets include packet header data of a network layer and a transport layer of a target network; For the current network traffic data packets within each first preset time period, the packet header data is processed by using the target feature function set and the preset network abnormal traffic detection model to generate a processing result; Based on the target relative entropy gain between the processing result and the preset model empirical distribution, the flow state information corresponding to the current network flow data packet is determined; wherein the flow state information includes abnormal flow state and normal flow state.
[0105] In one embodiment of the present application, when the processor executes the computer program, the processor further implements the following steps: Calculate the target relative entropy gain between the processing result and the preset model empirical distribution; If the duration of the target relative entropy gain exceeding the first preset threshold is greater than or equal to the first preset time period, determining that the flow state information corresponding to the current network flow data packet is an abnormal flow state; If the duration that the target relative entropy gain exceeds the first preset threshold is less than the first preset time period, it is determined that the traffic state information corresponding to the current network traffic data packet is a normal traffic state.
[0106] In one embodiment of the present application, when the processor executes the computer program, the processor further implements the following steps: Acquire a training data set; wherein the training data set includes a plurality of historical network traffic data packets within a second preset time period under a normal business state of the target network; Classify multiple historical network traffic data packets in the training data set to obtain at least one first classification result, and calculate a first weight corresponding to each first classification result; wherein the first weight is used to characterize the proportion of the number of historical network traffic data packets of each first classification result in the total first classification result; Based on the candidate feature function set and the number of classifications corresponding to the total first classification result, the preset model empirical distribution corresponding to the training data set is calculated.
[0107] In one embodiment of the present application, when the processor executes the computer program, the processor further implements the following steps: Calculate the initial model distribution based on the total number of preset data packet classifications; Traversing each candidate feature function in the candidate feature function set in turn, adding the currently traversed candidate feature function to the intermediate feature function set, and obtaining an updated feature function set; Based on the updated feature function set, multiple historical network traffic data packets in the training data set are classified to obtain at least one second classification result, and a second weight corresponding to each second classification result is calculated; wherein the second weight is used to characterize the proportion of the number of historical network traffic data packets of each second classification result in the total second classification result; Based on the initial model distribution, the updated feature function set and the second weight, calculating the current model distribution corresponding to the training data set; Calculate the current relative entropy gain between the current model distribution and the preset model empirical distribution, and continue to update the intermediate feature function set based on the current relative entropy gain to generate the target feature function set and the preset network abnormal traffic detection model.
[0108] In one embodiment of the present application, when the processor executes the computer program, the processor further implements the following steps: Comparing the current relative entropy gain with a second preset threshold value to generate a comparison result; If the comparison result does not meet the preset conditions, the candidate feature function corresponding to the current relative entropy gain is removed from the intermediate feature function set, and other candidate feature functions in the candidate feature function set are traversed in sequence, and the above steps of continuing to update the intermediate feature function set based on the current relative entropy gain are repeated; If the comparison result meets the preset conditions, the candidate feature function corresponding to the current relative entropy gain is retained in the intermediate feature function set, and other candidate feature functions in the candidate feature function set are traversed in turn, and the above steps of continuing to update the intermediate feature function set based on the current relative entropy gain are repeated; The intermediate feature function set that meets the preset update cutoff condition is used as the target feature function set.
[0109] In one embodiment of the present application, when the processor executes the computer program, the processor further implements the following steps: Based on the current relative entropy gain, the intermediate feature function set is continuously updated to generate an intermediate network abnormal traffic detection model; After processing the intermediate network abnormal traffic detection model using a test data set and a verification data set, a preset network abnormal traffic detection model is generated; wherein the test data set and the verification data set include multiple historical network traffic data packets within a third preset time period of the target network under an abnormal business state, and the third preset time period is less than the second preset time period.
[0110] In one embodiment of the present application, when the processor executes the computer program, the processor further implements the following steps: Acquire multiple classification label information; wherein the classification label information includes network layer protocol type, transport layer protocol type, destination port and TCP flag; Based on the multiple classification label information, the total number of preset data packet classifications is obtained.
[0111] The computer device provided in the embodiment of the present application has similar implementation principles and technical effects to those of the above-mentioned method embodiment, and will not be described in detail here.
[0112] In one embodiment of the present application, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the following steps are implemented: Acquire a plurality of current network traffic data packets within a first preset time period; wherein the current network traffic data packets include packet header data of a network layer and a transport layer of a target network; For the current network traffic data packets within each first preset time period, the packet header data is processed by using the target feature function set and the preset network abnormal traffic detection model to generate a processing result; Based on the target relative entropy gain between the processing result and the preset model empirical distribution, the flow state information corresponding to the current network flow data packet is determined; wherein the flow state information includes abnormal flow state and normal flow state.
[0113] In one embodiment of the present application, when the computer program is executed by a processor, the following steps are further implemented: Calculate the target relative entropy gain between the processing result and the preset model empirical distribution; If the duration of the target relative entropy gain exceeding the first preset threshold is greater than or equal to the first preset time period, determining that the flow state information corresponding to the current network flow data packet is an abnormal flow state; If the duration that the target relative entropy gain exceeds the first preset threshold is less than the first preset time period, it is determined that the traffic state information corresponding to the current network traffic data packet is a normal traffic state.
[0114] In one embodiment of the present application, when the computer program is executed by a processor, the following steps are further implemented: Acquire a training data set; wherein the training data set includes a plurality of historical network traffic data packets within a second preset time period under a normal business state of the target network; Classify multiple historical network traffic data packets in the training data set to obtain at least one first classification result, and calculate a first weight corresponding to each first classification result; wherein the first weight is used to characterize the proportion of the number of historical network traffic data packets of each first classification result in the total first classification result; Based on the candidate feature function set and the number of classifications corresponding to the total first classification result, the preset model empirical distribution corresponding to the training data set is calculated.
[0115] In one embodiment of the present application, when the computer program is executed by a processor, the following steps are further implemented: Calculate the initial model distribution based on the total number of preset data packet classifications; Traversing each candidate feature function in the candidate feature function set in turn, adding the currently traversed candidate feature function to the intermediate feature function set, and obtaining an updated feature function set; Based on the updated feature function set, multiple historical network traffic data packets in the training data set are classified to obtain at least one second classification result, and a second weight corresponding to each second classification result is calculated; wherein the second weight is used to characterize the proportion of the number of historical network traffic data packets of each second classification result in the total second classification result; Based on the initial model distribution, the updated feature function set and the second weight, calculating the current model distribution corresponding to the training data set; Calculate the current relative entropy gain between the current model distribution and the preset model empirical distribution, and continue to update the intermediate feature function set based on the current relative entropy gain to generate the target feature function set and the preset network abnormal traffic detection model.
[0116] In one embodiment of the present application, when the computer program is executed by a processor, the following steps are further implemented: Comparing the current relative entropy gain with a second preset threshold value to generate a comparison result; If the comparison result does not meet the preset conditions, the candidate feature function corresponding to the current relative entropy gain is removed from the intermediate feature function set, and other candidate feature functions in the candidate feature function set are traversed in sequence, and the above steps of continuing to update the intermediate feature function set based on the current relative entropy gain are repeated; If the comparison result meets the preset conditions, the candidate feature function corresponding to the current relative entropy gain is retained in the intermediate feature function set, and other candidate feature functions in the candidate feature function set are traversed in sequence, and the above steps of continuing to update the intermediate feature function set based on the current relative entropy gain are repeated; The intermediate feature function set that meets the preset update cutoff condition is used as the target feature function set.
[0117] In one embodiment of the present application, when the computer program is executed by a processor, the following steps are further implemented: Based on the current relative entropy gain, the intermediate feature function set is continuously updated to generate an intermediate network abnormal traffic detection model; After processing the intermediate network abnormal traffic detection model using a test data set and a verification data set, a preset network abnormal traffic detection model is generated; wherein the test data set and the verification data set include multiple historical network traffic data packets within a third preset time period of the target network under an abnormal business state, and the third preset time period is less than the second preset time period.
[0118] In one embodiment of the present application, when the computer program is executed by a processor, the following steps are further implemented: Acquire multiple classification label information; wherein the classification label information includes network layer protocol type, transport layer protocol type, destination port and TCP flag; Based on the multiple classification label information, the total number of preset data packet classifications is obtained.
[0119] The computer-readable storage medium provided in this embodiment has similar implementation principles and technical effects to those of the above method embodiments, and will not be described in detail here.
[0120] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application 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. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0121] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.
[0122] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A method for detecting abnormal network traffic, characterized in that: The method comprises: Acquire a plurality of current network traffic data packets within a first preset time period; wherein the current network traffic data packets include packet header data of a network layer and a transport layer of a target network; For the current network traffic data packets within each first preset time period, the packet header data is processed by a target feature function set and a preset network abnormal traffic detection model to generate a processing result; Based on the target relative entropy gain between the processing result and the preset model empirical distribution, the flow state information corresponding to the current network flow data packet is determined; wherein the flow state information includes abnormal flow state and normal flow state.
2. The method according to claim 1, characterized in that The determining, based on the target relative entropy gain between the processing result and the preset model empirical distribution, the flow state information corresponding to the current network flow data packet comprises: Calculating a target relative entropy gain between the processing result and a preset model empirical distribution; If the duration for which the target relative entropy gain exceeds the first preset threshold is greater than or equal to the first preset time period, determining that the flow state information corresponding to the current network flow data packet is an abnormal flow state; If the duration that the target relative entropy gain exceeds the first preset threshold is less than the first preset time period, it is determined that the traffic state information corresponding to the current network traffic data packet is a normal traffic state.
3. The method according to claim 1 or 2, characterized in that: The generation process of the preset model empirical distribution includes: Acquire a training data set; wherein the training data set includes a plurality of historical network traffic data packets of the target network within a second preset time period under a normal business state; Classify multiple historical network traffic data packets in the training data set to obtain at least one first classification result, and calculate a first weight corresponding to each first classification result; wherein the first weight is used to characterize the proportion of each first classification result in the number of historical network traffic data packets in the total first classification result; Based on the candidate feature function set and the number of classifications corresponding to the total first classification result, the preset model empirical distribution corresponding to the training data set is calculated.
4. The method according to claim 3, characterized in that The construction process of the preset network abnormal traffic detection model includes: Calculate the initial model distribution based on the total number of preset data packet classifications; Traversing each candidate feature function in the candidate feature function set in turn, adding the currently traversed candidate feature function to the intermediate feature function set, and obtaining an updated feature function set; Based on the updated feature function set, multiple historical network traffic data packets in the training data set are classified to obtain at least one second classification result, and a second weight corresponding to each second classification result is calculated; wherein the second weight is used to characterize the proportion of the number of historical network traffic data packets of each second classification result in the total second classification result; Calculating a current model distribution corresponding to the training data set based on the initial model distribution, the updated feature function set and the second weight; Calculate the current relative entropy gain between the current model distribution and the preset model empirical distribution, and continue to update the intermediate feature function set based on the current relative entropy gain to generate the target feature function set and the preset network abnormal traffic detection model.
5. The method according to claim 4, characterized in that The step of continuing to update the intermediate feature function set based on the current relative entropy gain to generate a target feature function set includes: Comparing the current relative entropy gain with a second preset threshold to generate a comparison result; If the comparison result does not meet the preset condition, the candidate feature function corresponding to the current relative entropy gain is removed from the intermediate feature function set, and other candidate feature functions in the candidate feature function set are traversed in sequence, and the above step of continuing to update the intermediate feature function set based on the current relative entropy gain is repeated; If the comparison result satisfies the preset condition, the candidate feature function corresponding to the current relative entropy gain is retained in the intermediate feature function set, and other candidate feature functions in the candidate feature function set are traversed in sequence, and the above step of continuing to update the intermediate feature function set based on the current relative entropy gain is repeated; The intermediate feature function set that meets the preset update cutoff condition is used as the target feature function set.
6. The method according to claim 4 or 5, characterized in that: The method further comprises: Continuing to update the intermediate feature function set based on the current relative entropy gain to generate an intermediate network abnormal traffic detection model; After processing the intermediate network abnormal traffic detection model using a test data set and a verification data set, the preset network abnormal traffic detection model is generated; wherein the test data set and the verification data set include multiple historical network traffic data packets within a third preset time period of the target network under an abnormal business state, and the third preset time period is less than the second preset time period.
7. The method according to claim 4 or 5, characterized in that: The method further comprises: Acquire multiple classification label information; wherein the classification label information includes network layer protocol type, transport layer protocol type, destination port and TCP flag; Based on the multiple classification label information, the total number of the preset data packet classifications is obtained.
8. A network abnormal traffic detection device, characterized in that: The device comprises: An acquisition module, used to acquire current network traffic data packets within a plurality of first preset time periods; wherein the current network traffic data packets include packet header data of a network layer and a transport layer of a target network; A processing module, for processing the packet header data of the current network traffic data packets within each first preset time period by using a target feature function set and a preset network abnormal traffic detection model to generate a processing result; A determination module is used to determine the flow state information corresponding to the current network flow data packet based on the target relative entropy gain between the processing result and the preset model empirical distribution; wherein the flow state information includes abnormal flow state and normal flow state.
9. An electronic device, characterized in that: The electronic device includes a processor and a memory, wherein the memory stores at least one instruction, at least one program, a code set or an instruction set, and the at least one instruction, the at least one program, the code set or the instruction set is loaded and executed by the processor to implement the steps of the method described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The storage medium stores at least one instruction, at least one program, a code set or an instruction set, and the at least one instruction, the at least one program, the code set or the instruction set is loaded and executed by the processor to implement the steps of the method described in any one of claims 1 to 7.
