Training method and device of traffic classification model and nonvolatile storage medium
A two-layer meta-learner model with base learner models enhances DDoS traffic detection accuracy by training on diverse traffic data, effectively classifying DDoS attacks.
Patent Information
- Application Number
- CN202411081192.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-07
- Publication Date
- 2024-12-03
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing DDoS traffic classification methods struggle to accurately detect new types of DDoS attacks due to their limitations in feature code matching and statistical analysis, leading to low detection accuracy.
A two-layer meta-learner model comprising multiple base learner models, such as support vector machines, random forests, and K-nearest neighbors, is trained using test traffic data to enhance DDoS traffic detection accuracy by determining control weights and performing weighted average calculations.
The proposed model effectively classifies DDoS traffic, improving detection accuracy and addressing the limitations of existing methods in handling new attack types.
Smart Images

Figure CN119071029A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of network security protection, and specifically, to a training method, device and non-volatile storage medium for a traffic classification model. Background Art
[0002] SDN (Software Defined Network) is a new type of network architecture. Its core lies in layering the control plane and the data plane to make network management simpler and to facilitate deployment in various network environments. It is especially suitable for multi-tenant data center network scenarios. Specifically, SDN frees the control of the network from traditional hardware devices and manages it through a centralized controller (such as an OpenFlow controller). The controller communicates with network devices (such as switches and routers) through a southbound interface (such as the OpenFlow protocol), collects network status information and sends down flow tables to achieve flexible control of network traffic.
[0003] DDoS (Distributed Denial of Service) attack is a type of attack that uses a distributed network to initiate a large number of requests to occupy the target server or network resources. Attackers control multiple computers or devices (commonly known as "zombie machines") to launch coordinated attacks, making the target system unable to provide services normally due to overload. DDoS attacks are distributed, difficult to track and defend, and pose a serious threat to the target system. With the rapid development of network technology, the frequency and scale of DDoS attacks continue to rise, posing a huge challenge to network security. Therefore, the importance of DDoS traffic detection has become increasingly prominent. Through effective traffic detection, DDoS attacks can be discovered and responded to in a timely manner, protecting the normal operation of network systems and preventing serious consequences such as data leakage and service interruption.
[0004] In the SDN network architecture, the DDoS attack server sends a large number of false IP address data packets to the switch, which forwards them to the controller because the switch has no matching flow table entries. By taking advantage of this processing delay, DDoS attacks can easily cause the centralized controller to overload and exhaust CPU, memory and other resources.
[0005] There are many types of DDoS attacks, and there are many new types of attacks. Network-side DDoS attacks mainly include the following methods: ICMP Ping flood attack, TCP SYN flood attack, and UDP flood attack. However, existing DDoS traffic classification methods mainly include methods based on feature code matching and statistical analysis, which often have limitations when facing the endless new types of DDoS attacks.
[0006] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention
[0007] The embodiments of the present application provide a training method, device and non-volatile storage medium for a traffic classification model to at least solve the technical problem of low DDoS traffic detection accuracy caused by the fact that existing DDoS traffic classification methods are insufficient to cope with the endless stream of new DDoS attacks.
[0008] According to one aspect of an embodiment of the present application, a method for training a traffic classification model is provided, comprising: obtaining test traffic data, wherein the test traffic data includes attack traffic data and non-attack traffic data; training the traffic classification model through the test traffic data, and determining a control weight of the traffic classification model based on the training result, wherein the traffic classification model includes a base learner model set and a two-layer meta-learner model, wherein the base learner model set includes multiple base learner models of different types, and the two-layer meta-learner model is a classifier model connected to multiple base learner models, and the outputs of the multiple base learner models are the inputs of the two-layer meta-learner model.
[0009] Optionally, the type of the base learner model includes at least one of the following: a support vector machine model, a random forest model, a K-nearest neighbor machine learning model, and the type of the two-layer meta-learner model includes a logistic regression classifier model.
[0010] Optionally, training the traffic classification model through test traffic data includes: training and testing each base learner model in the traffic classification model according to the test traffic data to obtain test results of each base learner model; determining the input data of the two-layer meta-learner model according to the full set of test results of each base learner model, and training and testing the two-layer meta-learner model based on the input data.
[0011] Optionally, the training method of the traffic classification model also includes: determining the weight of the output results of each base learner model based on the performance test indicators in the test results corresponding to each base learner model; performing weighted average calculation on the output results of each base learner model based on the weight, and using the calculation results as a training set to train the meta-learner model.
[0012] Optionally, the training method of the traffic classification model further includes: inputting the test traffic data as a training data set into the two-layer meta-learner model, thereby training the two-layer meta-learner model.
[0013] Optionally, obtaining test traffic data includes: collecting non-attack traffic data through a physical machine in a test network, wherein the test network includes at least one of the following: a soft-defined network controller, a switch, an attack server, a physical machine, a target machine; collecting attack traffic data through a target machine in the test network while simulating attack behavior through the test network; determining test traffic data based on the non-attack traffic data and the attack traffic data.
[0014] Optionally, determining the test traffic data based on the non-attack traffic data and the attack traffic data includes: taking the non-attack traffic data and the attack traffic data as the initial traffic data; deduplicating the initial traffic data based on the hash value of each traffic in the initial traffic data; and performing missing value filling and noise data filtering on the deduplicated initial traffic data to obtain the test traffic data.
[0015] Optionally, after obtaining the test traffic data, the method also includes: obtaining traffic characteristics from the test traffic data, wherein the feature type of the traffic characteristics includes at least one of the following: average number of flow table items, average number of flow packets, average number of bytes, network port growth rate, source IP address growth rate, average flow table item duration, flow table item matching rate, and convection rate; constructing a traffic feature vector based on the traffic characteristics, and constructing a traffic feature vector matrix based on the traffic feature vector; determining a training set and a test set based on the traffic feature vector matrix, wherein the training set is used to train the traffic classification model, and the test set is used to verify the accuracy of the classification results of the traffic classification model.
[0016] According to another aspect of an embodiment of the present application, a traffic classification method is also provided. The traffic classification method is applicable to a traffic classification model trained by a traffic classification model training method, and includes: obtaining traffic data to be classified; classifying the traffic data to be classified using the trained traffic classification model to obtain a classification result, wherein the traffic classification model includes a base learner model set and a two-layer meta-learner model, the base learner model set includes multiple different types of base learner models, the meta-learner model is a classifier model connected to multiple base learner models, and the outputs of the multiple base learner models are the inputs of the two-layer meta-learner model, and the classification result is used to determine whether there is attack traffic data in the traffic data.
[0017] According to another aspect of an embodiment of the present application, a training device for a traffic classification model is also provided, including: a data acquisition module, used to obtain test traffic data, wherein the test traffic data includes attack traffic data and non-attack traffic data; a training module, used to train the traffic classification model through the test traffic data, and determine the control weight of the traffic classification model based on the training result, wherein the traffic classification model includes a base learner model set and a two-layer meta-learner model, wherein the base learner model set includes multiple different types of base learner models, and the two-layer meta-learner model is a classifier model connected to multiple base learner models, and the output of the multiple base learner models is the input of the two-layer meta-learner model.
[0018] According to another aspect of an embodiment of the present application, a non-volatile storage medium is provided, in which a program is stored, wherein when the program is running, a device where the non-volatile storage medium is located is controlled to execute a training method for a traffic classification model.
[0019] According to another aspect of an embodiment of the present application, an electronic device is further provided, including: a memory and a processor, the processor being configured to run a program stored in the memory, wherein the program executes a training method for a traffic classification model when the program is running.
[0020] According to another aspect of an embodiment of the present application, a computer program product is also provided, including a computer program, and when the computer program is executed by a processor, a training method for a traffic classification model is implemented.
[0021] In the embodiment of the present application, a traffic classification model is used to classify traffic, the traffic classification model is trained through traffic data, and the trained traffic classification is used to detect DDoS traffic, thereby achieving the purpose of accurately classifying DDoS traffic and normal traffic, thereby achieving the technical effect of accurately detecting DDoS, and further solving the technical problem of low accuracy of DDoS traffic detection caused by the fact that the existing DDoS traffic classification method is not sufficient to cope with the endless new types of DDoS attacks. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0023] Figure 1 It is a structural schematic diagram of a computer terminal (mobile device) provided according to an embodiment of the present application;
[0024] Figure 2 It is a flow chart of a method for training a traffic classification model provided according to an embodiment of the present application;
[0025] Figure 3 It is a flowchart of a method for acquiring test flow data provided in an embodiment of the present application;
[0026] Figure 4 It is a schematic diagram of a network topology diagram of a local test SDN network provided according to an embodiment of the present application;
[0027] Figure 5 is a schematic diagram of a cross-validation process provided according to an embodiment of the present application;
[0028] Figure 6 It is a flow chart of a traffic classification model training method provided according to an embodiment of the present application;
[0029] Figure 7 A schematic diagram of a specific construction process of a decision tree provided in an embodiment of the present application;
[0030] Figure 8 It is a structural schematic diagram of a training device for a traffic classification model provided according to an embodiment of the present invention. DETAILED DESCRIPTION
[0031] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings 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 should fall within the scope of protection of the present application.
[0032] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0033] In order to better understand the embodiments of the present application, the technical terms involved in the embodiments of the present application are explained as follows:
[0034] SDN (Software Defined Network): An emerging network architecture technology that aims to improve the flexibility and programmability of the network. The core idea is to separate the control plane from the data plane of the network and realize the programmability of the network through an open API.
[0035] Machine learning: An important branch of artificial intelligence that uses algorithms to process large amounts of data and discover patterns and regularities in the data, thereby guiding the computer to make predictions or decisions.
[0036] DDoS (Distributed Denial of Service): A network traffic attack method that controls multiple attack points or uses botnets to send a large number of requests to the target to exhaust its bandwidth and server resources, causing the target to be unable to provide services normally. This attack is distributed, making it difficult to defend.
[0037] Support Vector Machine (SVM): A generalized linear classifier in a supervised learning mode that seeks to minimize structured risk to improve the generalization ability of the learning machine and to find the optimal decision hyperplane for classification.
[0038] Random Forest (RF): An ensemble learning algorithm based on multiple decision trees (DT), which constructs multiple decision trees through self-sampling and random feature selection, and integrates their prediction results to improve prediction stability and accuracy. Among them, the decision tree is a classification and prediction tool with a tree structure, in which each internal node represents a test of an attribute, each branch represents the result of the test, and each leaf node (terminal node) has a category label (classification).
[0039] K-Nearest Neighbours (KNN): A simple and commonly used supervised learning algorithm for classification and regression problems. The core idea is that if most of the k most similar samples (the closest samples in the feature space) of a sample belong to a certain category, then the sample also belongs to that category.
[0040] Logistic Regression (LR): An algorithm for classification problems, especially binary classification problems. By building a prediction model, the input features are mapped to probability values between 0 and 1, indicating the likelihood of an event occurring. Logistic regression uses the Sigmoid function to convert the output of the linear regression model into probability values, making the prediction results easier to interpret. The algorithm has low computational cost and is easy to implement and understand.
[0041] TCP (Transmission Control Protocol): A connection-oriented, reliable, byte stream-based transport layer communication protocol in the TCP / IP protocol suite, used to provide reliable data transmission services.
[0042] UDP (User Datagram Protocol): A simple datagram-oriented transport layer protocol that is connectionless and does not guarantee reliable delivery.
[0043] SYN (Synchronize Sequence Numbers): A handshake signal used by the TCP / IP protocol to establish a connection. When a client and a server establish a connection, both parties are required to synchronize sequence numbers. SYN is the synchronization handshake signal used to establish a connection.
[0044] ACK (ACKnowlegde Character, confirmation character): In the TCP / IP protocol, if the recipient successfully receives the data, ACK will be sent back as a transmission control character to indicate that the data is received correctly.
[0045] TTL (Time To Live): In computer networks, the TTL field exists in the IPv4 header and is an 8-bit field. It indicates the maximum number of network segments or forwarding times (hops) that an IP packet is allowed to pass through before being discarded. The TTL value decreases by one every time it passes through a router or gateway until the TTL value is zero, and the packet is discarded.
[0046] In the related art, the DDoS traffic detection method based on feature code matching needs to continuously update the feature library to cope with new attack modes, but the update of the feature library often lags behind the changes in the attack; the DDoS traffic detection method based on statistical analysis may be affected by normal traffic fluctuations, resulting in a high false positive or false negative rate. Therefore, there is a problem of low accuracy of DDoS traffic detection caused by the fact that the existing DDoS traffic classification method is not sufficient to cope with the endless new DDoS attacks. In order to solve this problem, a relevant solution is provided in the embodiments of the present application, which is described in detail below.
[0047] According to an embodiment of the present application, a method embodiment of a method for training a traffic classification model is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0048] The method embodiments provided in the embodiments of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Figure 1 FIG. 1 shows a hardware structure block diagram of a computer terminal (or mobile device) for implementing a training method for a traffic classification model. Figure 1 As shown, the computer terminal 10 (or mobile device 10) may include one or more (102a, 102b, ..., 102n are used to illustrate) processors 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory 104 for storing data, and a transmission module 106 for communication functions. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the BUS bus), a network interface, a power supply and / or a camera. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above electronic device. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations are shown.
[0049] It should be noted that the one or more processors 102 and / or other data processing circuits described above may generally be referred to herein as "data processing circuits". The data processing circuits may be embodied in whole or in part as software, hardware, firmware, or any other combination thereof. In addition, the data processing circuit may be a single independent processing module, or may be incorporated in whole or in part into any of the other components in the computer terminal 10 (or mobile device). As described in the embodiments of the present application, the data processing circuit acts as a processor control (e.g., selection of a variable resistor terminal path connected to an interface).
[0050] The memory 104 can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the training method of the traffic classification model in the embodiment of the present application. The processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, that is, realizing the vulnerability detection method of the above-mentioned application. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the computer terminal 10 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0051] The transmission device 106 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of the computer terminal 10. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0052] The display may be, for example, a touch screen liquid crystal display (LCD) that enables a user to interact with a user interface of the computer terminal 10 (or mobile device).
[0053] In the above operating environment, the present application embodiment provides a method for training a traffic classification model, such as Figure 2 As shown, the method comprises the following steps:
[0054] Step S202, obtaining test traffic data, wherein the test traffic data includes attack traffic data and non-attack traffic data;
[0055] In some embodiments of the present application, obtaining test traffic data includes SDN network topology construction, traffic data collection, and traffic data cleaning. Figure 3 A specific test flow data acquisition process is shown.
[0056] like Figure 3 As shown, first, in step S302, a local test SDN network is established. In a typical SDN network environment, the network element devices involved mainly include an SDN controller, an Open VSwitch switch, a firewall, a host, and a traffic detection and defense system. Figure 4 A network topology diagram of a local test SDN network is shown, such as Figure 4 As shown, these devices work together to detect and prevent DDoS traffic.
[0057] In the SDN network architecture, the SDN controller communicates with the network switch through the OpenFlow protocol to configure, monitor and manage network devices; the Open VSwitch switch is responsible for forwarding and switching network traffic, transmitting data packets from one network node to another; the firewall is responsible for monitoring and filtering traffic in and out of the network to ensure that only legitimate traffic can pass through the network. The traffic detection and defense system is responsible for collecting network traffic data, performing preprocessing and feature extraction, providing input for the machine learning model, and detecting DDoS attack traffic based on the machine learning model.
[0058] In terms of communication relationships, these network element devices communicate through network protocols and interfaces. The details are as follows:
[0059] SDN controller: communicates with the Open VSwitch switch through the southbound API interface to achieve precise control and management of network traffic. At the same time, the SDN controller also communicates with the application layer through the northbound API, receives network policies and management instructions from the application layer, and converts them into specific flow table rules and sends them to the OVS switch.
[0060] Open VSwitch switch: communicates with the SDN controller through the southbound API and connects to the physical machine to achieve communication between virtual machines, containers and physical hosts. Open VSwitch switch also supports multiple tunnel protocols such as VLAN, VXLAN, GRE, etc., and can forward and route packets between different network layers.
[0061] Physical machine: Connects to the SDN network through the Open VSwitch switch, receiving and sending network traffic. Applications or virtual machines on the physical machine can communicate with other devices in the SDN network through the Open VSwitch switch.
[0062] Firewall: communicates with other devices in the SDN network, receiving and sending network traffic. The firewall can obtain network policies and security instructions through the interface with the SDN controller, and filter and monitor network traffic according to the instructions. At the same time, the firewall can also communicate with the physical machine to protect the security of applications and data on the physical machine.
[0063] Before building a DDoS traffic detection model based on integrated machine learning, a large amount of network traffic data needs to be collected. This traffic data should include normal traffic and DDoS attack traffic to ensure that the algorithm model can accurately and comprehensively learn the difference between the two. Figure 3As shown, after the local test SDN network is established, it is step S304 to collect normal network traffic data on the normal physical machine for the data control group; the attack server and the target machine are mainly used for DDoS simulation attacks. In terms of physical devices, the Linux virtual machine on the server is used as the DDoS source, that is, the attack server, and the Apache Web server running the Web application is used as the attacked target machine. After setting up the local test network, the physical networks of the SDN controller, Open VSwitch switch, attack server, normal physical machine, and target machine are connected, and the Ping command is used for testing to confirm that the communication between the devices is normal. Use normal physical machines to communicate with each other, and capture flow table items on the Open VSwitch switch to obtain the OpenFlow flow table items of normal traffic. Normal traffic data is used for control group data, and the classification label value is normal traffic. Connect the DDoS target machine running the Apache Web service to the attack server, and disconnect the network connection of the normal physical machine. Then, the DDoS attack source (attack server) is used to simulate and collect abnormal traffic containing DDoS attacks, and step S306 is performed to simulate and collect normal network traffic, and various types of DDoS attacks are carried out on the target machine for about 3 minutes every 10 minutes, and this is continued for multiple times. Common DDoS attack types involved in this embodiment include TCP SYN floods, UDP floods, ICMP Ping floods, etc. When launching a simulated DDoS attack, the DDoS traffic is mixed with normal traffic. After the target machine receives normal traffic and DDoS traffic, the OpenFlow flow table entry containing the DDoS attack traffic is captured on the switch side.
[0064] like Figure 3 As shown, after data collection, step S308 is performed to pre-process the flow data. The original flow data often contains noise, duplicates and irrelevant information. The presence of these impurity data will seriously affect the subsequent analysis and model training effect. Data cleaning and other pre-processing methods are required to improve the quality of test data. The cleaning process includes removing duplicate data, processing missing values, filtering noise, etc. The cleaned sample data is converted into a csv table file format.
[0065] Specifically, the first step in the data cleaning process is to remove duplicate data. Due to the complexity of network traffic, the same data packet may be recorded multiple times by the packet capture tool, so it is necessary to remove these duplicates through the corresponding algorithm to avoid these redundant data from interfering with subsequent analysis. Because the collected traffic data is real-time data and the data volume is large, a hash-based deduplication method is adopted. The hash function can map data of any length to a shorter fixed-length hash value. If the content of two data streams is the same, then their hash values must be the same.
[0066] Specifically, a hash value is calculated for each data stream. A set Set is used to store the hash values that have appeared. When a new data stream is received, its hash value is calculated and checked whether the value has appeared in the set. If it has appeared, it means that the data stream is duplicated and should be discarded; otherwise, its hash value is added to the set and the data stream is retained. The algorithm has a low time complexity and can complete deduplication in a shorter time.
[0067] Secondly, handle missing values properly. In network traffic data, some fields may be missing for various reasons. For these missing values, you can choose to fill (not recommended, it may increase the false positive rate), delete or ignore them.
[0068] Finally, filter out noise data. Noise data refers to data that does not match the characteristics of normal traffic or DDoS attack traffic, which may be caused by network jitter, hardware failure, etc. By setting reasonable thresholds and filtering rules, noise data can be effectively removed.
[0069] like Figure 3 As shown, after preprocessing the flow data, step S310 is performed to extract flow features. Feature extraction is a key step in training the flow classification model. We define the data collection period as T. For flow data, the elements of the feature vector mainly include the mean number of flow table items, the mean number of flow packets, the mean number of bytes, the network port growth rate, the source IP address growth rate, the mean flow table duration, the flow table item matching rate, the contraflow ratio, etc. within the collection period T.
[0070] Specifically, each data is calculated by the following formula:
[0071] The average number of flow entries F T : Under a DDoS attack, the attacking host usually triggers a large number of flow table entry requests in a short period of time, which may cause flow table overload and affect the normal forwarding function of the network. The average number of flow table entries in the collection period T is defined as:
[0072]
[0073] Among them, the acquisition period T is differentiated and sliced, a t Indicates the number of flow table entries added in a unit time interval.
[0074] Average number of flow packets S T : Under DDoS attacks, the attacking host generates a large number of false source IP address flow packets in a short period of time to conceal its real IP address, causing the generation speed of the attack flow to increase significantly, and the number of data packets contained in each flow to increase significantly. The average number of flow packets within the collection period T is defined as:
[0075]
[0076] Among them, b i Indicates the number of packets in the i-th flow table entry, and n is the total number of flow table entries in the sampling period T.
[0077] Mean number of bytes B T : Under DDoS attacks, the attacking host generates a large number of data packets in a short period of time, which means that the number of data packet bytes in a short period of time also increases significantly, so the number of data packet bytes in each flow increases significantly. The average number of bytes in the collection period T is defined as:
[0078]
[0079] Among them, c i Indicates the number of bytes of the data packet of the i-th flow table entry, and n is the total number of flow table entries in the sampling period T.
[0080] Network port speed P T : Under normal network conditions, the external ports and corresponding services of the access host are relatively stable. Due to DDoS attacks, the attacking host will conceal its real port numbers in large quantities and forge false port numbers, resulting in a significant increase in the number of ports and the speed of change. The network port growth rate is defined as:
[0081]
[0082] Among them, the acquisition period T is differentiated and sliced, d t Indicates the number of port number increases in a unit time interval.
[0083] Source IP address speed increase I T : Under normal network conditions, the external IP address of the access host is stable. Due to DDoS attacks, the attacking host will conceal its real IP address in large quantities and forge false source IP addresses to send flow packets, resulting in a significant increase in the number and change rate of source IP addresses. The source IP address growth rate is defined as:
[0084]
[0085] Among them, the acquisition period T is differentiated and sliced, e t Indicates the number of source IP addresses added in a unit time interval.
[0086] Average duration of flow entry J T :Under normal circumstances, the flow table lifetime is relatively stable. Under DDoS attacks, the attacking host continuously sends a large number of useless data packets, which causes the flow table entries in the switch to be continuously activated, and their duration increases. The average duration of the flow table entry is defined as:
[0087]
[0088] Among them, f i Indicates the duration of the i-th flow entry, and n is the total number of flow entries in the sampling period T.
[0089] Flow table matching rate α T :Check the matching success rate of flow table items. Under DDoS attacks, there may be a large amount of invalid or abnormal traffic trying to match flow table items, resulting in a decrease in the matching rate. Define the flow table item matching rate within the collection period T as:
[0090]
[0091] Among them, n T Indicates the total number of flow table entries in the collection period T (including successful and failed matches); m T Indicates the total number of flow entries that are successfully matched during the collection period.
[0092] Convection ratio β T : In general, the switch can handle most data flows without asking the controller for guidance. However, under a DDoS attack, the attacking host sends a large number of forged or invalid data packets, causing the switch to frequently send Packet_in messages to the controller to request convection processing, which in turn leads to a significant increase in the convection ratio. The convection ratio is defined as:
[0093]
[0094] Among them, x T Indicates the number of Packet_in messages sent by the switch to the SDN controller; T Indicates the number of packets actually forwarded by the switch.
[0095] like Figure 3 As shown, after the flow feature extraction, step S312 is performed to construct the flow feature vector. The flow classification model mainly learns and trains the numerical fields in the flow feature data. The constructed feature vector should include a feature column and a label column. The data column includes {flow table item number mean F T , the mean number of flow packets S T , the average number of bytes is B T , network port speed P T , Source IP address speed increase I T , the mean duration of flow table entries J T , flow entry matching rate α T , convection ratio β T The label column (i.e., classification result) is a Boolean value, with normal traffic being 0 and DDoS abnormal traffic being 1.
[0096] like Figure 3As shown, after constructing the traffic feature vector, step S314 is performed to construct a feature vector matrix, the feature column is ah, where the mean number of flow table items is a, the mean number of flow packets is b, the mean number of bytes is c, the network port growth rate is d, the source IP address growth rate is e, the mean flow table item duration is f, the flow table item matching rate is g, and the contravariance ratio is h. The label column is i, and n is the number of samples. As above, the feature vector matrix can be expressed as:
[0097]
[0098] like Figure 3 As shown, after constructing the characteristic vector matrix, step S316 is performed to normalize the flow characteristic data using a 0-1 standard normalization method, as follows:
[0099] Assume that the value of a certain attribute A of n sample points has a maximum value of max A , the minimum value is min A . Then the normalized value of the attribute of sample point A is After standard normalization, it is ensured that the training data values are in the range of 0-1, which is convenient for training and testing.
[0100] like Figure 3 As shown, after the traffic feature data is normalized, step S318 is performed to divide the data set into a training set and a test set. The training set is used to train a layer-based learner model such as a support vector machine, a random forest, and a K-nearest neighbor, and finally generate a corresponding binary classification model (normal traffic, DDoS traffic). The test set is used to verify the accuracy of the obtained binary classification model.
[0101] In some embodiments of the present application, a cross-validation method is used to divide the data set to improve the accuracy and performance of the model: the data set (abbreviated as D) is divided into k mutually exclusive subsets of similar size (the intersection is an empty set). Each subset is obtained from the data set D by stratified sampling while maintaining the consistency of data distribution as much as possible. Each training uses the union of k-1 subsets as the training set, and the remaining subset is used as the test set. Finally, k groups of training / test sets can be obtained, k trainings are performed, and the mean of the k test results is taken or decided by voting, which is k-fold cross validation. Figure 5 The specific cross-validation process is shown in Figure 2. Figure 5 As shown in the figure, a 5-fold cross validation is performed, and the data set is evenly divided into 5 mutually exclusive subsets through stratified sampling. The union of 4 subsets is used for each training, and the remaining 1 subset is used as the test set. Finally, 5 sets of training / test sets are obtained, and 5 trainings are performed. The average of the 5 test results or the voting result is taken to decide.
[0102] Step S204, training the traffic classification model by testing traffic data, and determining the control weight of the traffic classification model based on the training results, wherein the traffic classification model includes a base learner model set and a two-layer meta-learner model, the base learner model set includes multiple different types of base learner models, the two-layer meta-learner model is a classifier model connected to multiple base learner models, and the outputs of the multiple base learner models are the inputs of the two-layer meta-learner model.
[0103] In some embodiments of the present application, training the traffic classification model by testing traffic data includes the steps of constructing a layer of base learner model, testing and evaluating a layer of base learner model, etc. Figure 6 A flowchart of a specific traffic classification model training method is shown.
[0104] like Figure 6 As shown, first, step S602 is performed to determine the base learner of the DDoS traffic classification model. When constructing the Stacking ensemble learning DDoS detection model, a variety of machine learning models with good effects, strong interpretability, and adaptability to complex data are selected, such as support vector machines, K-nearest neighbors, random forests, etc. The responsibility of these models is to find the relationship between the original traffic data and the label (whether it is DDoS traffic), that is, to establish a hypothesis between the original data and the label.
[0105] The confusion matrix is used to judge the model effect. The confusion matrix is composed of four different combinations between the predicted label (Predicted label) and the correct label (True label). The four combinations are TP (True Positive), which means the true value is Positive and the model predicts the number of Positives; FN (False Negative), which means the true value is Positive and the model predicts the number of Negatives; FP (False Positive), which means the true value is Negative and the model predicts the number of Positives; TN (True Negative), which means the true value is Negative and the model predicts the number of Negatives. Three indicators are calculated through the confusion matrix, namely Accuracy (ACC), Missing Report Rate (MR), and False Alarm Rate (FR). The calculation formula is as follows:
[0106]
[0107]
[0108] like Figure 6As shown in the figure, after determining the base learner of the DDoS traffic classification model, a support vector machine machine learning model, a random forest machine learning model, and a K-nearest neighbor machine learning model are constructed respectively.
[0109] Specifically, perform step S604 to construct a support vector machine (SVM) machine learning model. Support vector machine is a supervised learning algorithm, the core of which is to find an optimal hyperplane to accurately divide data into different categories. The determination of this hyperplane depends entirely on the sample points closest to the hyperplane, namely the "support vectors". These support vectors are not only the determining factors of the position of the hyperplane, but also the cornerstone of the SVM model's ability to classify efficiently and accurately. For the SVM classification algorithm, the core is to carefully select and optimize the support vectors to improve the performance and adaptability of the SVM model.
[0110] In this embodiment, an 8-dimensional feature variable is selected, and the feature variable element is a hyperplane with a dimension of 7 set according to the 8-dimensional feature vector, which is used for the SVM classification algorithm. The function expression of the decision hyperplane is: W1X1+W2X2+....+W8X8+B=0. Where X i is the input 8-dimensional flow characteristic attribute value; B is the displacement term, which determines the distance between the hyperplane and the origin.
[0111] Decision hyperplane normal vector Each element of corresponds to its adjustable weight value of X. The dividing line of the decision hyperplane is the decision boundary. The selection of the hyperplane requires that the interval between normal traffic data points and abnormal traffic data points be maximized as much as possible.
[0112] Specifically, the positive hyperplane and negative hyperplane are calculated as: W1X1+W2X2+....+W m X m +B=1 and W1X1+W2X2+....+W m X m +B = -1. The goal of fitting is to maximize the distance L between the positive and negative hyperplanes. The larger the distance L, the higher the error tolerance of the data binary classification.
[0113] According to mathematical calculations, The problem is transformed into finding the normal vector of the decision hyperplane Minimum value of modulus
[0114]
[0115] Further converted into The minimum value of .
[0116] According to the constraint expression: (i=1,2,3,4...n, n is the total number of samples) to convert it into
[0117] Further converted into
[0118] According to the above constraints, combined with the Lagrange multiplier method: where λ i is the penalty coefficient for violating the constraint.
[0119] For W, B, λ i ,P i Calculate partial derivatives respectively. We get equations (1)-(4):
[0120]
[0121] 2λ i *P i =0 (4)
[0122] Combined with the derivation, the penalty coefficient λ for violating the constraint condition i ≥0(5).
[0123] Combined with the application of SVM algorithm principles based on Python algorithm, the SVM module of the machine learning sklearn library is imported to construct a support vector machine model.
[0124] Load the data set, initialize the SVM classifier, set the kernel function to linear, and the penalty coefficient to 1.
[0125] The evaluation indicators of the SVM base classifier in this example under training and testing with sample numbers (1000, 2000, 3000, 5000) are shown in the following table.
[0126]
[0127] It can be seen that the performance of a single SVM machine learning model still has room for improvement. The accuracy is high, but the underreporting rate is at a high level of 17.5%-22.1% in the sample space of 1000-5000. The analysis shows that the accuracy is guaranteed by dividing the decision hyperplane for classification, but the influence of anomalies and error points is still large, resulting in a relatively high false alarm rate.
[0128] Specifically, after constructing the support vector machine (SVM) machine learning model, step S606 is performed to construct a random forest machine learning model. Random forest is suitable for classification tasks with higher feature attribute dimensions. By performing bootstrap sampling and random feature selection on the original data set, multiple independent decision trees need to be constructed. Each decision tree is constructed based on a randomly sampled training set and a randomly selected feature subset. All decision trees are trained and predicted independently, and then their prediction results are voted or averaged to obtain the final prediction result.
[0129] For each independent decision tree, each internal node represents a test of the feature attribute, each branch represents the test result, and the leaf node represents the final category label (classification). When a new sample is input, the decision trees in the forest make judgments respectively and determine the sample category based on the final decision and voting results. The specific construction process of the decision tree is as follows: Figure 7 shown.
[0130] When training and predicting DDoS traffic, the random forest model needs to collect and analyze traffic data including multi-dimensional features: the mean number of flow table items F T , the mean number of flow packets S T , the average number of bytes is B T , network port speed P T , Source IP address speed increase I T , the mean duration of flow table entries J T , flow entry matching rate α T , convection ratio β T These data have been preprocessed, including cleaning, standardization, and normalization. Model training and prediction are performed based on the multi-dimensional feature data. The data dimension is high, and each independent decision tree is constructed by dividing the feature subset.
[0131] like Figure 7 As shown in the figure, each independent decision tree should have a basis for division. The root node includes all sample data sets at the beginning of training, and the leaf nodes represent the final classification of the model (i.e. normal traffic and DDoS attack traffic). The decision rule selects the rule with the largest information gain, and the decision tree with this rule can be given a larger weight.
[0132] Calculate information entropy and information gain:
[0133] Information entropy: The larger the information entropy, the more types of information it contains, the larger the amount of information, the more chaotic and scattered the information, and the lower the purity. Variable information entropy is usually calculated using the following formula:
[0134]
[0135] Among them, P(xi ) represents the probability of a certain information appearing; Ent (x) Represents the information entropy of information.
[0136] Information gain: The difference in information entropy before and after a data set is divided by a certain feature. Entropy can represent the uncertainty of a sample set. The greater the entropy, the greater the uncertainty of the sample. The difference in set entropy before and after the division is used to measure the effect of using the current feature to divide the sample set D. Information gain is equal to information entropy minus conditional entropy. The calculation method is as follows:
[0137] Information Entropy:
[0138] Conditional entropy:
[0139] Information Gain:
[0140] According to the data characteristics of the training set and the corresponding classification labels, the sample number n = 1000 is selected to calculate the information gain of the corresponding traffic data features. The two features with the largest information gain are the mean number of flow packets S T and the source IP address growth rate, select 6 independent decision trees, and select the mean number of flow packets S with the largest information gain T The source IP address growth rate is a fixed feature, and the other feature is randomly selected to create a decision tree {DT1, DT2...DT6}. The training samples are selected by stratified replacement sampling. Taking DT1 as an example, in this embodiment, the first internal node, the decision rule selects the mean value of the number of flow packets S T The average number of flow packets exceeds the threshold (more than 1000 flow packets within the sampling period T). If so, enter the left subtree and determine it as DDoS traffic, which still needs further verification; if not, it is determined to be normal traffic, which also needs further verification. The second internal node selects the average number of bytes B T If the average number of bytes exceeds the threshold (more than 50M within the sampling period T), it will further enter the left subtree, otherwise it will enter the right subtree. The third internal node selects the source IP address growth rate. The decision rule is that if the number of source IP addresses exceeds the threshold (more than 50 different IP addresses within the sampling period), if yes, it is determined to be DDoS traffic, if not, it is determined to be normal traffic.
[0141] Similarly, set the decision rules for {DT2...DT6} decision trees. Divide the training set and the test set, and train and test each decision tree of the random forest base classifier.
[0142] For each sample, the classification results of each decision tree are voted, and the classification result with the most votes is selected as the final result.
[0143] The following table shows the prediction accuracy of the random forest base classifier under training and testing in this example with different sample numbers (1000, 2000, 3000, 5000).
[0144]
[0145] As mentioned above, the accuracy of the random forest base classifier is high when the number of samples is small (N=1000) and when the number of samples is large (N=5000), reaching more than 93%.
[0146] The random forest classifier has excellent classification performance when processing multidimensional data such as traffic characteristics. The reason is that various feature combinations are selected to build decision trees and random samples, and the test results are obtained by voting to reduce the risk of overfitting.
[0147] During the construction process, the random forest classifier is also tuned: 1. Increase the number of decision trees: The performance of random forest depends on the number of decision trees, so increasing the number of decision trees can improve the accuracy of the model. But it should be noted that this will also increase the complexity of the calculation to a certain extent. 2. Limit the maximum depth of the decision tree: Too deep a decision tree may lead to overfitting, so limiting the maximum depth of the decision tree can avoid overfitting. 3. Adjust the number of randomly selected features: Random forest builds a decision tree by randomly selecting features. Adjusting the number of randomly selected features can control the complexity of the decision tree. Usually, the value of the feature sampling ratio is better between sqrt(n_features) and log2(n_features), where n_features is the number of features. 4. Prune the decision tree: The decision tree may contain too many leaf nodes. Pruning the decision tree can improve the accuracy of the model.
[0148] Specifically, after building the random forest machine learning model, proceed to step S608 to build a KNN (K-nearest neighbor) machine learning model: given a set of correctly classified data sets as a training set, calculate the k instances that are closest to the newly input instance and the training set, and on this basis check the number of categories in these k instances. The newly input instance category (label) is the category with the largest number.
[0149] Specifically, five training sets are defined as training_set and test_set as test_set. The sample points in the training set are represented as n+1-dimensional vectors: X = (x1, x2...x n ,y). Among them, x i are the feature attribute values, and y is the label column (classification). Similarly, the sample points in the test set are represented as: X′=(x′1,x′2...x′ n ,y′).
[0150] The "neighborhood" of the KNN algorithm can be measured using the Euclidean space distance metric: 11 ,x 12 ...x 1n ) and X2=(x 21 ,x 22 ...x 2n ) is the Euclidean space distance
[0151] Before measuring the Euclidean distance, the value of each attribute is normalized. The 0-1 standard normalization method can be adopted: Assume that the value of attribute A of n sample points, the maximum value is max A , the minimum value is min A . Then the normalized value of the attribute of sample point A is
[0152] Initially set the K value to 5, and calculate the number of training set sample points that are different from the test set sample points X′=(x′1,x′2...x′ n ,y′), select the 5 points with the smallest distance to the current point, count the frequency of occurrence of the categories of these 5 points, and finally return the category with the highest frequency as the predicted category of the current point.
[0153] It should be noted that if the K value is too small, it is easy to be affected by outliers and overfitting will occur; if the K value is too large, it is easy to have sample balance problems. The performance tuning of the KNN-based learner is achieved by cross-validation and adjusting the K value. In this example, the sample number n = 1000, 2000, 3000, 5000, etc. are selected, and K = 5, 7, 9, etc. are selected for training and evaluation.
[0154] After training, the training and testing results are shown in the following table.
[0155]
[0156] From the above training and test results, it can be seen that when the number of samples gradually increases, if the K value is as small as 5, the label prediction accuracy is lower than K=7 or K=9. When the number of samples is large, 5000, K=9 is selected, and the label prediction accuracy is 0.5% higher than when K=7 and 2.9% higher than when K=5, but the false alarm rate MR and false alarm rate FR do not decrease significantly. When the sample space is between 1000-5000, K=7 is selected based on the comprehensive evaluation indicators and computational complexity. If the accuracy is further considered, the K value can be appropriately increased.
[0157] Tuning of KNN model: 1. Adjust and select the appropriate K value: K value is an important parameter in KNN model, which means that when predicting a sample, the voting results of its nearest K neighbors are considered. Selecting the appropriate K value can be achieved through Bayesian optimization, cross-validation, etc. 2. Select the appropriate distance measurement method: KNN calculates the nearest neighbor based on the distance between instances. Common distance measurement methods include Euclidean distance, Manhattan distance, Minkowski distance, etc. Different distance measurement methods may affect the results, so it is necessary to select the appropriate distance measurement method according to the characteristics of the data and the problem. 3. Weight adjustment: In KNN, each neighbor contributes equally to the prediction result. In practical applications, different weights can be set for each neighbor according to its importance to better reflect its impact on the prediction result.
[0158] like Figure 6 As shown, after constructing the support vector machine machine learning model, the random forest machine learning model, and the K-nearest neighbor machine learning model respectively, step S610 is performed to determine the second-layer meta-learner of the DDoS traffic detection model. Determining the second-layer meta-learner of the DDoS traffic detection model, constructing the integrated learning model includes using the stacking method to determine the construction: using the output of the first-layer base learner model as the input of the second-layer meta-learner model to construct a hierarchical model structure. The second-layer meta-learner selects a relatively simple classification method, including selecting a logistic regression classification algorithm as the second-layer meta-learner.
[0159] Specifically, when building a logistic regression model, 8-dimensional data is used as the data set, and the model output is defined
[0160]
[0161] in, is the i-th element of the N-th sample data vector. In this example, n ranges from 1 to 8. ω i is the weight corresponding to the i-th element, b is the offset value, σ is the Sigmoid function, y (N) The label classification value of the Nth sample data.
[0162] Specifically,
[0163]
[0164]
[0165] Construct the loss function:
[0166] Constructing the optimizer:
[0167] like Figure 6As shown, after determining the second-layer meta-learner of the DDoS traffic detection model, step S612 is performed to train and test the Stacking ensemble learning model. After the initial traffic output is preprocessed, it is divided into a training set and a test set. The data set enters the first-layer base learner (support vector machine, random forest, K-nearest neighbor) for training and testing respectively, and three groups of test results are obtained respectively. The full set of the three groups of results is taken as the data input of the second-layer meta-learner (logistic regression), and training and testing are performed again to obtain the final result.
[0168] like Figure 6 As shown, after training and testing the Stacking ensemble learning model, step S614 is performed, and the evaluation of the tacking ensemble learning model is repeated: the sample size N = 1000, 2000, 3000, and 5000 are taken to repeat the evaluation. After the training of the improved Stacking ensemble learning model, the various evaluation indicators have been significantly improved. In the one-layer base learner model, the detection result of random forest (RF) is better than that of support vector machine and KNN. It defines the priority of decision rules by descending information gain, and makes full use of random decision trees and random samples to improve the interpretability of the model. It has good and stable classification performance, can better mine and analyze the various features of traffic data, and the accuracy is maintained at more than 92%, and the false alarm rate FR is relatively low. Secondly, the accuracy of the SVM classification algorithm does not increase significantly with the increase of sample size, and the false alarm rate is still high. The main reason is that when the sample size increases, after the training sample is fully fitted, the hyperplane shift is small, the classification ability effect is not significantly improved, and it is difficult to accurately identify some samples with low eigenvalues, resulting in a slight decrease in the false alarm rate. The KNN algorithm has good classification performance and high accuracy. After training the Stacking ensemble learning model, the classification accuracy is increased to more than 96%, the false alarm rate is reduced to less than 4%, and the false alarm rate is reduced to less than 3%. This shows that the Stacking ensemble learning model can effectively detect DDoS attacks, reduce false alarm rates and false alarm rates, has good robustness, and is suitable for detecting DDoS attacks in a big data SDN environment.
[0169] In other embodiments of the present application, the training traffic classification model also includes tuning the model using multiple methods, including: 1. Adding the original training set of a layer of base learners to the second-layer meta-learner: It helps the meta-learner learn the implicit relationship between the original training set and the new training set, thereby improving the prediction effect; 2. Adjusting data feature vectors and parameters: Modifying the data feature vectors and parameters of the first-layer base learner model, such as the random forest classification algorithm, adding more decision trees to seek higher accuracy, re-evaluating the contribution of decision tree leaf nodes to the prediction and pruning the decision tree; 3. Meta-learner tuning: Adjusting the regularization strength and loss function of the logistic regression, and finding a better parameter configuration; Adjusting the classification threshold of the logistic regression, the default classification threshold is 0.5, and in this example, it is appropriately adjusted to 0.4 to increase the accuracy; 4. Weighting according to the classification effect of the base learner: Based on the relative advantages and disadvantages of the performance of each base learner in the first layer, the results output by each learner in the first layer are weighted averaged to form a new training set to be added to the second-layer meta-learner for training, which can further improve the prediction effect.
[0170] Through the above steps, a traffic classification method with better prediction performance, better robustness, stronger generalization ability, and more flexible adjustment and optimization scheme can be realized, which has broad application prospects in the field of SDN network security. By combining multiple machine learning algorithms and the collaboration of network element devices, this method can detect DDoS attacks in network traffic in real time and effectively protect the network from malicious traffic, thereby achieving the technical effect of accurately detecting DDoS, and further solving the technical problem of low accuracy of DDoS traffic detection caused by the fact that the existing DDoS traffic classification method is not sufficient to cope with the endless new DDoS attacks.
[0171] Specifically, machine learning algorithms have many advantages. After learning the characteristics of normal and abnormal traffic, machine learning models can automatically detect and classify DDoS attack traffic. Compared with traditional methods, machine learning has the following advantages: 1. Strong adaptability: machine learning models can adaptively adjust detection strategies according to changes in network traffic and effectively respond to new DDoS attacks. 2. High precision: through training with a large number of data sets, machine learning models can learn more refined traffic features and improve the accuracy and reliability of detection. 3. Low false alarm rate: machine learning algorithms can distinguish normal and abnormal traffic with high precision, reduce false alarm rates, and reduce unnecessary intervention and losses. 4. Low false alarm rate: machine learning algorithms are trained based on a large amount of data, build appropriate models and features, optimize hyperparameters through cross-validation, grid search, etc., and improve prediction capabilities through integrated learning methods. 5. Strong generalization ability: through multi-model integrated learning schemes, hyperparameter optimization and feature engineering can be applied, which has stronger generalization ability than a single model.
[0172] Specifically, in the detection of DDoS traffic attacks in the SDN network environment, traditional single machine learning models, such as support vector machines (SVM), K nearest neighbors (KNN) and random forests, each have their own unique advantages, but when dealing with complex and changeable network DDoS attacks, especially in the context of a surge in the number of sample points and interference from abnormal points, the performance of these models is often significantly affected, resulting in high false positive and false negative rates. The present invention innovatively constructs and applies an integrated learning model based on Stacking. This model adopts a multi-level architecture. First, a variety of complex classification algorithms (such as SVM, KNN, random forest) are used as base learner models. Various base learners conduct in-depth mining and classification of traffic data features from different angles, effectively improving the interpretability and classification effect of the model. Then, the results of the base learners are integrated and retrained through a relatively simple classification algorithm (such as logistic regression) to construct an integrated model with better performance and stronger interpretability. After testing, the Stacking integrated learning model used in the present invention shows more excellent performance compared with the traditional solution. Through fine tuning and verification, the accuracy of the model in DDoS attack detection has been improved to more than 96%, the false alarm rate has dropped to less than 4%, and the false alarm rate has also dropped to less than 3%. The improvement of these indicators not only shows that DDoS attacks in the network can be detected more accurately, but also can reduce unnecessary false alarms and false alarms, and improve the security and stability of the network. In addition, the Stacking ensemble learning model shows good robustness. In the big data SDN environment, the network traffic data is huge and complex and changeable. The Stacking ensemble learning model used in this invention can run stably and accurately detect DDoS attacks, providing strong support for the security protection of the network. At the same time, the Stacking ensemble learning model integrates multiple base learner models and uses a meta-learner to integrate training results, with a more flexible and scalable adjustment and optimization method. A more flexible optimization method can be achieved by adding a two-layer meta-learner to the original training set, adjusting parameters and feature vectors, tuning the meta-learner, and weighting the base learner, further improving the performance and robustness of the overall model.
[0173] An embodiment of the present application provides a traffic classification method, which is applicable to a traffic classification model trained by the above-mentioned traffic classification model training method, including: obtaining traffic data to be classified; using the trained traffic classification model to classify the traffic data to be classified to obtain a classification result, wherein the traffic classification model includes a base learner model set and a two-layer meta-learner model, the base learner model set includes multiple different types of base learner models, the meta-learner model is a classifier model connected to multiple base learner models, and the outputs of the multiple base learner models are the inputs of the two-layer meta-learner model, and the classification result is used to determine whether there is attack traffic data in the traffic data.
[0174] The present application embodiment provides a training device for a traffic classification model. Figure 8 is a schematic diagram of the structure of the device, such as Figure 8 As shown, the device includes: a data acquisition module 80, which is used to obtain test traffic data, wherein the test traffic data includes attack traffic data and non-attack traffic data; a training module 82, which trains a traffic classification model through the test traffic data, and determines the control weight of the traffic classification model according to the training result, wherein the traffic classification model includes a base learner model set and a two-layer meta-learner model, the base learner model set includes multiple different types of base learner models, the two-layer meta-learner model is a classifier model connected to multiple base learner models, and the output of the multiple base learner models is the input of the two-layer meta-learner model.
[0175] In some embodiments of the present application, the type of the base learner model includes at least one of the following: a support vector machine model, a random forest model, a K-nearest neighbor machine learning model, and the type of the two-layer meta-learner model includes a logistic regression classifier model.
[0176] In some embodiments of the present application, the training module 82 trains the traffic classification model through test traffic data, including: training and testing each base learner model in the traffic classification model according to the test traffic data to obtain the test results of each base learner model; determining the input data of the two-layer meta-learner model according to the full set of the test results of each base learner model, and training and testing the two-layer meta-learner model based on the input data.
[0177] In some embodiments of the present application, the training method of the traffic classification model also includes: determining the weight of the output results of each base learner model based on the performance test indicators in the test results corresponding to each base learner model; performing weighted average calculation on the output results of each base learner model based on the weight, and using the calculation results as a training set to train the meta-learner model.
[0178] In some embodiments of the present application, the training method of the traffic classification model further includes: inputting the test traffic data as a training data set into the two-layer meta-learner model, thereby training the two-layer meta-learner model.
[0179] In some embodiments of the present application, the data acquisition module 80 obtains test traffic data including: collecting non-attack traffic data through a physical machine in a test network, wherein the test network includes at least one of the following: a soft-defined network controller, a switch, an attack server, a physical machine, and a target machine; collecting attack traffic data through a target machine in the test network while simulating attack behavior through the test network; and determining test traffic data based on the non-attack traffic data and the attack traffic data.
[0180] In some embodiments of the present application, the data acquisition module 80 determines the test traffic data based on the non-attack traffic data and the attack traffic data, including: taking the non-attack traffic data and the attack traffic data as the initial traffic data; deduplicating the initial traffic data based on the hash value of each traffic in the initial traffic data; filling missing values and filtering noise data on the initial traffic data after deduplication to obtain the test traffic data.
[0181] In some embodiments of the present application, after the data acquisition module 80 obtains the test traffic data, the method also includes: obtaining traffic characteristics from the test traffic data, wherein the characteristic type of the traffic characteristics includes at least one of the following: average number of flow table items, average number of flow packets, average number of bytes, network port growth rate, source IP address growth rate, average flow table item duration, flow table item matching rate, and convection rate; constructing a traffic feature vector based on the traffic characteristics, and constructing a traffic feature vector matrix based on the traffic feature vector; determining a training set and a test set based on the traffic feature vector matrix, wherein the training set is used to train the traffic classification model, and the test set is used to verify the accuracy of the classification results of the traffic classification model.
[0182] It should be noted that the various modules in the training device of the above-mentioned traffic classification model can be program modules (for example, a set of program instructions that implement a certain specific function) or hardware modules. For the latter, it can be expressed in the following forms, but is not limited to this: the expression form of each of the above-mentioned modules is a processor, or the functions of each of the above-mentioned modules are implemented by a processor.
[0183] An embodiment of the present application provides a non-volatile storage medium, in which a program is stored, wherein when the program is running, a device where the non-volatile storage medium is located is controlled to execute the following traffic classification model training method, including: obtaining test traffic data, wherein the test traffic data includes attack traffic data and non-attack traffic data; training the traffic classification model through the test traffic data, and determining the control weight of the traffic classification model according to the training result, wherein the traffic classification model includes a base learner model set and a two-layer meta-learner model, wherein the base learner model set includes multiple base learner models of different types, and the two-layer meta-learner model is a classifier model connected to multiple base learner models, and the outputs of the multiple base learner models are the inputs of the two-layer meta-learner model.
[0184] An embodiment of the present application provides an electronic device, comprising: a memory and a processor, the processor being used to run a program stored in the memory, wherein when the program is running, the following traffic classification model training method is executed, comprising: obtaining test traffic data, wherein the test traffic data includes attack traffic data and non-attack traffic data; training the traffic classification model through the test traffic data, and determining the control weight of the traffic classification model according to the training result, wherein the traffic classification model includes a base learner model set and a two-layer meta-learner model, wherein the base learner model set includes multiple base learner models of different types, and the two-layer meta-learner model is a classifier model connected to multiple base learner models, and the outputs of the multiple base learner models are the inputs of the two-layer meta-learner model.
[0185] An embodiment of the present application provides a computer program product, including a computer program. When the computer program is executed by a processor, it implements the following traffic classification model training method, including: obtaining test traffic data, wherein the test traffic data includes attack traffic data and non-attack traffic data; training the traffic classification model through the test traffic data, and determining the control weight of the traffic classification model according to the training result, wherein the traffic classification model includes a base learner model set and a two-layer meta-learner model, wherein the base learner model set includes multiple base learner models of different types, and the two-layer meta-learner model is a classifier model connected to multiple base learner models, and the outputs of the multiple base learner models are the inputs of the two-layer meta-learner model.
[0186] In the above embodiments of the present application, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.
[0187] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units can be a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0188] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0189] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0190] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the relevant technology or all or part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk, etc. Various media that can store program codes.
[0191] The above is only a preferred embodiment of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A method for training a traffic classification model, characterized in that: include: Acquire test traffic data, wherein the test traffic data includes attack traffic data and non-attack traffic data; The traffic classification model is trained using the test traffic data, and the control weight of the traffic classification model is determined based on the training results, wherein the traffic classification model includes a base learner model set and a two-layer meta-learner model, wherein the base learner model set includes multiple base learner models of different types, and the two-layer meta-learner model is a classifier model connected to multiple base learner models, and the outputs of the multiple base learner models are the inputs of the two-layer meta-learner model.
2. The method for training a traffic classification model according to claim 1, characterized in that: The type of the base learner model includes at least one of the following: a support vector machine model, a random forest model, a K-nearest neighbor machine learning model, and the type of the two-layer meta-learner model includes a logistic regression classifier model.
3. The training method of the traffic classification model according to claim 1 is characterized in that: Training the traffic classification model using the test traffic data includes: Training and testing each of the base learner models in the traffic classification model according to the test traffic data to obtain test results of each of the base learner models; The input data of the two-layer meta-learner model is determined according to the full set of test results of each of the base learner models, and the two-layer meta-learner model is trained and tested according to the input data.
4. The method for training a traffic classification model according to claim 3, characterized in that: The training method of the traffic classification model also includes: Determining the weight of the output results of each of the base learner models according to the performance test indicators in the test results corresponding to each of the base learner models; The output results of each of the base learner models are weighted averaged according to the weights, and the calculation results are used as training sets to train the meta learner model.
5. The method for training a traffic classification model according to claim 1, characterized in that: The training method of the traffic classification model also includes: The test traffic data is input into the two-layer meta-learner model as a training data set, so as to train the two-layer meta-learner model.
6. The method for training a traffic classification model according to claim 1, characterized in that: Obtaining test traffic data includes: The non-attack traffic data is collected through a physical machine in a test network, wherein the test network includes at least one of the following: a soft-defined network controller, a switch, an attack server, a physical machine, and a target machine; In the case of simulating attack behavior through the test network, collecting the attack traffic data through a target machine in the test network; The test traffic data is determined according to the non-attack traffic data and the attack traffic data.
7. The method for training a traffic classification model according to claim 6, characterized in that: Determining the test traffic data according to the non-attack traffic data and the attack traffic data includes: Using the non-attack traffic data and the attack traffic data as initial traffic data; Deduplication processing is performed on the initial traffic data according to the hash value of each traffic in the initial traffic data; The initial traffic data after deduplication processing is subjected to missing value filling processing and noise data filtering to obtain the test traffic data.
8. The method for training a traffic classification model according to claim 1, characterized in that: After obtaining the test flow data, the method further includes: Obtaining traffic characteristics from the test traffic data, wherein the characteristic type of the traffic characteristics includes at least one of the following: average number of flow table entries, average number of flow packets, average number of bytes, network port growth rate, source IP address growth rate, average duration of flow table entries, flow table entry matching rate, and convection rate; Constructing a flow feature vector according to the flow feature, and constructing a flow feature vector matrix according to the flow feature vector; A training set and a test set are determined according to the traffic feature vector matrix, wherein the training set is used to train the traffic classification model, and the test set is used to verify the accuracy of the classification result of the traffic classification model.
9. A traffic classification method, the traffic classification method being applicable to a traffic classification model trained by the traffic classification model training method according to any one of claims 1 to 8: Obtain traffic data to be classified; The trained traffic classification model is used to classify the traffic data to be classified to obtain a classification result, wherein: The traffic classification model includes a base learner model set and a two-layer meta-learner model. The base learner model set includes multiple base learner models of different types. The meta-learner model is a classifier model connected to multiple base learner models, and the outputs of the multiple base learner models are the inputs of the two-layer meta-learner model. The classification result is used to determine whether there is attack traffic data in the traffic data.
10. A training device for a traffic classification model, characterized in that: include: A data acquisition module, used to obtain test traffic data, wherein the test traffic data includes attack traffic data and non-attack traffic data; A training module is used to train the traffic classification model through the test traffic data, and determine the control weight of the traffic classification model according to the training result, wherein the traffic classification model includes a base learner model set and a two-layer meta-learner model, the base learner model set includes multiple different types of base learner models, the two-layer meta-learner model is a classifier model connected to multiple base learner models, and the outputs of the multiple base learner models are the inputs of the two-layer meta-learner model.
11. A non-volatile storage medium, characterized in that: The non-volatile storage medium stores a program, wherein when the program is running, the device where the non-volatile storage medium is located is controlled to execute the training method of the traffic classification model described in any one of claims 1 to 8.
12. An electronic device, characterized in that: include: A memory and a processor, wherein the processor is used to run a program stored in the memory, wherein the program, when running, executes the training method of the traffic classification model described in any one of claims 1 to 8.
13. A computer program product, characterized in that It comprises a computer program, which, when executed by a processor, implements the training method of the traffic classification model according to any one of claims 1 to 8.
Citation Information
Patent Citations
Network intrusion detection method and system based on ensemble learning
CN113922985A
Stacking-based multi-feature fusion malicious encrypted traffic identification method and device
CN116346452A
Low-rate denial of service attack detection method based on TCP time-frequency domain characteristics
CN117336063A
Ensemble machine learning models incorporating a model trust factor
US20230044102A1
