# Design of Network Intrusion Detection Model Based on TCA

Authors: Quan Wen
Journal: Security and Communication Networks
 (2022)

---

## Abstract

The traditional machine learning model cannot effectively identify the new network traffic data set, resulting in the model failure. Therefore, in this paper, by analyzing the problems of current network intrusion detection (NID) and combining the application of transfer theory in the detection model, a NID model based on transfer component analysis (TCA) is proposed. Among them, the specific mathematical derivation of the algorithm and the detection process of transfer model are introduced in detail. Then, the classification performance of KNN and SVM based on TCA algorithm for network abnormal traffic is compared. The results show that the TCA algorithm proposed in this paper can effectively improve the accuracy of NID, which is meaningful to expand the application scope of network abnormal traffic detection scheme based on machine learning.


---

## Body

## 1. Introduction

With the rapid development of Internet in social life, people's attention to network security has gradually increased, and more network traffic data have brought great challenges to traditional intrusion detection systems. When the traditional machine learning method is used for intrusion detection, it is necessary to extract features manually, then use feature selection method to distinguish the most meaningful features, and finally adopt to discover new threats [1, 2]. In any case, with the rise of new assaults and the changing improvement of assault situations, these techniques for AI are confronted with numerous challenges in building highlights. Various elements chose for realized noxious examples are totally appropriate for obscure or new kinds of vindictive examples, and traditional machine learning needs a lot of manpower and material resources, while deep learning has the characteristics of automatic learning and feature extraction [3–5]. However, the existing neural network can only be used in a closed or static network environment. When performing classification, all possible classes are already known during training; therefore, if unknown classes appear, the existing detection system cannot correctly identify them, which will greatly threaten the network security.Besides, the abnormal traffic detection schemes based on machine learning all require that the training and testing data sets have the same feature distribution. However, with the diversity and secrecy of network abnormal traffic, the detection based on signature and specification is not reliable. Once the time of traffic collection, the node location, and traffic type change, it cannot identify effectively, when the traditional machine learning model is applied to new network traffic data sets, resulting failure in model [6, 7]. Usually, tag data are difficult to obtain and expensive, and at the same time, numerous expired data are not fully utilized. By introducing the transfer learning theory into the NID system, it can solve the learning problem of the target domain without or with only little labeled data by transferring the knowledge of the source domain and use the original data in the shared subspace to train the basic classifier model and detect the new sample flow [8].Since the 1980s, NID has been studied. Faced with the ever-changing network attacks and increasing traffic data, the following problems still exist in intrusion detection system.


### 1.1. Low Training Efficiency

Although the deep learning model can extract advanced abstract features, it also sacrifices computing resources. To extract effective features from large and high-dimensional data, it will increase more computational cost and time. Therefore, how to solve the problem of large and high-dimensional data, improve the training efficiency of the model, and ensure the accuracy of the system classifier is particularly important.


### 1.2. The Real-Time Performance of Intrusion Detection Is Low

Reliable intrusion detection system can quickly identify the network when it is attacked, and network security managers can take corresponding security measures to defend it. This requires high real-time performance of intrusion detection algorithms, but the current intrusion detection algorithms have low real-time performance. When the network is invaded, the network security managers cannot find it in time to intercept it, which attacks the network system. Therefore, it is necessary to solve the real-time problem of intrusion detection algorithm.


### 1.3. The Detection Rate of Rare Sample Data Is Low

The detection rate of rare attacks is extremely low due to bit of rare attacks. The increase of the number of features and the imbalance of data are the key reasons for the low detection accuracy. If a hacker makes use of a rare attack, the intrusion detection system will have no way to successfully warn or intercept it, thus endangering the security of the network system and causing serious consequences. Therefore, it is necessary to study the problems of multi-classification and data imbalance in intrusion detection.Therefore, the identification of abnormal network traffic data can effectively support the location of network intrusion behaviors; especially for the discovery of unknown attacks, this paper improves and combines the transfer learning theory in the research of NID, aiming at solving the problems derived from classification in NID, such as scarcity of tags, inconsistent distribution of source and destination data, and difficulty in distinguishing unknown attacks, so as to meet the original intention of pursuing higher accuracy.


## 1.1. Low Training Efficiency

Although the deep learning model can extract advanced abstract features, it also sacrifices computing resources. To extract effective features from large and high-dimensional data, it will increase more computational cost and time. Therefore, how to solve the problem of large and high-dimensional data, improve the training efficiency of the model, and ensure the accuracy of the system classifier is particularly important.


## 1.2. The Real-Time Performance of Intrusion Detection Is Low

Reliable intrusion detection system can quickly identify the network when it is attacked, and network security managers can take corresponding security measures to defend it. This requires high real-time performance of intrusion detection algorithms, but the current intrusion detection algorithms have low real-time performance. When the network is invaded, the network security managers cannot find it in time to intercept it, which attacks the network system. Therefore, it is necessary to solve the real-time problem of intrusion detection algorithm.


## 1.3. The Detection Rate of Rare Sample Data Is Low

The detection rate of rare attacks is extremely low due to bit of rare attacks. The increase of the number of features and the imbalance of data are the key reasons for the low detection accuracy. If a hacker makes use of a rare attack, the intrusion detection system will have no way to successfully warn or intercept it, thus endangering the security of the network system and causing serious consequences. Therefore, it is necessary to study the problems of multi-classification and data imbalance in intrusion detection.Therefore, the identification of abnormal network traffic data can effectively support the location of network intrusion behaviors; especially for the discovery of unknown attacks, this paper improves and combines the transfer learning theory in the research of NID, aiming at solving the problems derived from classification in NID, such as scarcity of tags, inconsistent distribution of source and destination data, and difficulty in distinguishing unknown attacks, so as to meet the original intention of pursuing higher accuracy.


## 2. Analysis of Problems in NID

The process of NID is shown in Figure1, in which the solid line represents the transmission direction of data and control instructions in the system, and the dotted line represents the reaction of the terminal nodes in the system to possible intrusion.Figure 1
Architecture of the NID system.A universal intrusion detection system is mainly composed of monitoring object, data collection, data storage, data processing, analysis and detection, and alarm modules [9].Data collection: the data collected at this stage are analyzed to find traces of suspicious activities, which can be host, network activity log, command-based log, application-based log, etc.Data storage: intrusion detection systems usually store data indefinitely or for a long time for future reference, so the amount of data is usually very large.Analysis and detection: the processing module is the core of the intrusion detection system where an algorithm for detecting suspicious behavior is executed. Traditionally, intrusion analysis and detection algorithms are divided into three categories: misuse detection, anomaly detection, and hybrid detection.Configuration data: it is the most delicate piece of interruption location framework. It contains data connected with the activity of interruption location framework itself, for example, data about when and how to gather information, how to manage interruption, and so forth.Reference data: it stores information about known intrusion signatures or profiles of normal behaviors where knowledge about system behavior can be used to update configuration information.Alarm: this piece of the framework handles all the result from the interruption recognition framework. The result can be a programmed reaction to the interruption or a suspicious behavior alarm of the system security officer.In summary, the process of intrusion detection is shown in Figure2.Figure 2
Process of intrusion detection.The general process of intrusion detection is that first, the detection system collects the required original data from the data source and then preprocesses the data to get the data format that the system can recognize. After identification and detection by the detection engine, the detection result is obtained and the response is made according to the security policy set by the administrator.


## 3. Implementation of Transfer Learning in NID

The main idea of transfer learning is to apply the trained machine learning model to other related fields. Through transfer learning, the generalization of another task can be improved by the knowledge learned in one task [10, 11].The main advantage of learning is that based on a small amount of data, the performance of neural network can be rapidly improved in a short time. Usually, training neural networks from scratch requires numerous data, but in reality, getting such a lot of data is unimaginable all the time. Through move learning, a solid AI model can be worked with moderately little preparation information, in light of the fact that the model has been preprepared. The main implementation mode is shown in Figure3:(1)
Adopting the Training Model. If users want to solve task (A) but there are not enough data to train the neural network, they can find the connected errand B with a ton of information, train the profound neural network on task B, and utilize the model as the beginning stage to tackle (A) while whether the entire model or a couple of layers are required relies upon the issue to be addressed.(2)
Pretraining Model. Use trained models, such as nine pretraining models provided in Keras, which can be used for transfer learning, prediction, feature extraction, and fine-tuning.(3)
Feature Extraction. With the help of the deep learning training model, the features of the shallow network can be used to show the elements to be learned, that is, the representation of the original data, without using the network output, so that the size of the data set can be reduced, thus reducing the calculation time.Figure 3
Implementation of transfer learning.In intrusion detection, the knowledge learned from known network attacks is used to enhance the detection of new network attacks. The source domain (SD) and the TD, respectively, represent the training and testing data sets in machine learning tasks, and both the data include normal and abnormal traffic records. In a generalized scenario, the attacks in the SD are marked, while the attack in the TD is new and unmarked. The purpose of learning in intrusion detection is to use source data to help distinguish new attacks from TDs, as shown in Figure4.Figure 4
NID based on transfer learning.


## 4. NID Model Based on TCA

### 4.1. Establishment of the Problem Model

Define the SD network traffic data set with label asDS,XS=xss=1ns∈Rm×ns. As a feature input, the corresponding tag set YS=yss=1ns∈R1×ns is set as an output, and a new network traffic data set with different structures is defined as a TD after data preprocessing. DT,XT=xtt=1nτ∈Rm×nT is set as a feature input, and the sample label is unknown.m is the traffic characteristics extracted from the SD and the TD. Considering the edge distribution of SD traffic and TD traffic PXS≠QXT, the SD model cannot be trained to detect the abnormal traffic in the TD.The solution of this paper is to find a suitable transformationΦ to make PΦXS≈QΦXT, and PYS|ΦXS≈PYT|ΦXT, so that the corresponding labels can be trained ΦXS and the corresponding label. YS can be used to train the data of the TD traffic ΦXT, where the SD traffic data ΦXS and the classifier trained by the corresponding label matches the TD traffic ΦXT can used to classify the data and detect the abnormal traffic.The following two conditions of transformation functionΦ must be met:(1)
Minimize the gap between the edge distributionPXS and QXT(2)
Retain the internal attributes ofXS and XT to the maximum extent possibleΦ is a feature mapping between SD and TD caused by general kernel, while the essence of TCA algorithm is to reduce the distance between the distribution of SD P and target source distribution Q, and the distribution distance of the objective function P and Q is shown in(1)DistXS′,XT′=1n1∑i=1n1Φxsi−1n2∑i=1n2ΦxTiH2,where H is a universal regenerative kernel Hilbert space, Φ is a feature mapping caused by a kernel, XS′ and XT′, respectively, representing the characteristics of the SD traffic and the TD traffic in the transformation space, and n1 and n2, respectively, represent the number of samples contained in each. Therefore, if the conversion function Φ is found, the objective function can be calculated.It is very difficult to direct explicit definition of nonlinear transformationΦ and calculate the distance between features. Therefore, a kernel matrix K is introduced by using the kernel embedding method, where formula (1) is rewritten as follows:(2)DistXS′,XT′=trKL,where KL represents the distance and is used to measure the difference of probability distribution K of traffic characteristics in different network environments, as shown in(3)K=KSSKS,TKT,SKT,T∈Rn1+n2×n1+n2,where KS,S,KT,T,andKS,T represent the inner core matrix composed of the features of the SD, the TD, and the synthesis domain L, respectively, which are defined as(4)Lij=1n12xi,xj∈XS,1n22xi,xj∈XT,−1n1n2otherwise,.n1 and n2, respectively, represent the number of samples contained in each.Therefore, the distance of the above objective function is transformed into an operation problem between matrices, which is shown in(5)trKL−λtrK,where λ≥0 is a trade-off parameter, trKL is used to minimize the difference between the distributions of the two fields, and λtrK is used to maximize the variance of feature space.As can be seen from the above discussion and definition, formula (5) is a semidefinite programming problem in mathematics, and it takes a lot of time to solve it by general methods. Therefore, the kernel matrix K in formula (3) is reduced by the dimension reduction, which is broken down into K=KK−1/2K−1/2K. The final kernel matrix can be expressed by(6)K˜=KK−1/2W˜W˜TK−1/2K=KWWTK,where W=K−1/2W˜. The distance between characteristics of traffic in SD and TD in transformation space XS′ and XT′ can be converted into(7)DistXS′,XT′=trKWWTKL=trWTKLKW.Under the minimization rule, the normalization termtrWTW is used to control complexity W, and the final objective function is transformed into(8)minWtrWTW+μ×trWTKLKW,where μ>0 is a trade-off parameter, so that the sample matrix X∗=KWKW in the shared subspace can be calculated. It ensures that the distance between the SD and the TD is reduced, and the mapped data have the largest variance, which satisfies the set of abovementioned transformation function Φ.To sum up, the working principle of TCA is as follows: the goal of TCA is to find an optimal shared feature subspace, in which the distribution difference between the SD and the TD can be minimized, and then the unlabeled data in the TD can be classified by using the classifier trained in the SD.


### 4.2. Detection Model

In this paper, KNN, SVM, and RF are used as basic classifiers, and a network abnormal traffic detection model based on TCA is designed as shown in Figure5. The specific detection process is divided into the following five steps:(1)
Extract network traffic characteristics and corresponding characteristic values of a TD(2)
Migrate the traffic characteristics and original characteristics of the TD to be identified to the shared subspace(3)
Train the base classifier with SD traffic data in the shared subspace(4)
Adopt the base classifier to detect the features of the TD after traffic transformation(5)
Calculate the detection accuracy, and then evaluate the experimental resultsFigure 5
Detection model based on TCA.


## 4.1. Establishment of the Problem Model

Define the SD network traffic data set with label asDS,XS=xss=1ns∈Rm×ns. As a feature input, the corresponding tag set YS=yss=1ns∈R1×ns is set as an output, and a new network traffic data set with different structures is defined as a TD after data preprocessing. DT,XT=xtt=1nτ∈Rm×nT is set as a feature input, and the sample label is unknown.m is the traffic characteristics extracted from the SD and the TD. Considering the edge distribution of SD traffic and TD traffic PXS≠QXT, the SD model cannot be trained to detect the abnormal traffic in the TD.The solution of this paper is to find a suitable transformationΦ to make PΦXS≈QΦXT, and PYS|ΦXS≈PYT|ΦXT, so that the corresponding labels can be trained ΦXS and the corresponding label. YS can be used to train the data of the TD traffic ΦXT, where the SD traffic data ΦXS and the classifier trained by the corresponding label matches the TD traffic ΦXT can used to classify the data and detect the abnormal traffic.The following two conditions of transformation functionΦ must be met:(1)
Minimize the gap between the edge distributionPXS and QXT(2)
Retain the internal attributes ofXS and XT to the maximum extent possibleΦ is a feature mapping between SD and TD caused by general kernel, while the essence of TCA algorithm is to reduce the distance between the distribution of SD P and target source distribution Q, and the distribution distance of the objective function P and Q is shown in(1)DistXS′,XT′=1n1∑i=1n1Φxsi−1n2∑i=1n2ΦxTiH2,where H is a universal regenerative kernel Hilbert space, Φ is a feature mapping caused by a kernel, XS′ and XT′, respectively, representing the characteristics of the SD traffic and the TD traffic in the transformation space, and n1 and n2, respectively, represent the number of samples contained in each. Therefore, if the conversion function Φ is found, the objective function can be calculated.It is very difficult to direct explicit definition of nonlinear transformationΦ and calculate the distance between features. Therefore, a kernel matrix K is introduced by using the kernel embedding method, where formula (1) is rewritten as follows:(2)DistXS′,XT′=trKL,where KL represents the distance and is used to measure the difference of probability distribution K of traffic characteristics in different network environments, as shown in(3)K=KSSKS,TKT,SKT,T∈Rn1+n2×n1+n2,where KS,S,KT,T,andKS,T represent the inner core matrix composed of the features of the SD, the TD, and the synthesis domain L, respectively, which are defined as(4)Lij=1n12xi,xj∈XS,1n22xi,xj∈XT,−1n1n2otherwise,.n1 and n2, respectively, represent the number of samples contained in each.Therefore, the distance of the above objective function is transformed into an operation problem between matrices, which is shown in(5)trKL−λtrK,where λ≥0 is a trade-off parameter, trKL is used to minimize the difference between the distributions of the two fields, and λtrK is used to maximize the variance of feature space.As can be seen from the above discussion and definition, formula (5) is a semidefinite programming problem in mathematics, and it takes a lot of time to solve it by general methods. Therefore, the kernel matrix K in formula (3) is reduced by the dimension reduction, which is broken down into K=KK−1/2K−1/2K. The final kernel matrix can be expressed by(6)K˜=KK−1/2W˜W˜TK−1/2K=KWWTK,where W=K−1/2W˜. The distance between characteristics of traffic in SD and TD in transformation space XS′ and XT′ can be converted into(7)DistXS′,XT′=trKWWTKL=trWTKLKW.Under the minimization rule, the normalization termtrWTW is used to control complexity W, and the final objective function is transformed into(8)minWtrWTW+μ×trWTKLKW,where μ>0 is a trade-off parameter, so that the sample matrix X∗=KWKW in the shared subspace can be calculated. It ensures that the distance between the SD and the TD is reduced, and the mapped data have the largest variance, which satisfies the set of abovementioned transformation function Φ.To sum up, the working principle of TCA is as follows: the goal of TCA is to find an optimal shared feature subspace, in which the distribution difference between the SD and the TD can be minimized, and then the unlabeled data in the TD can be classified by using the classifier trained in the SD.


## 4.2. Detection Model

In this paper, KNN, SVM, and RF are used as basic classifiers, and a network abnormal traffic detection model based on TCA is designed as shown in Figure5. The specific detection process is divided into the following five steps:(1)
Extract network traffic characteristics and corresponding characteristic values of a TD(2)
Migrate the traffic characteristics and original characteristics of the TD to be identified to the shared subspace(3)
Train the base classifier with SD traffic data in the shared subspace(4)
Adopt the base classifier to detect the features of the TD after traffic transformation(5)
Calculate the detection accuracy, and then evaluate the experimental resultsFigure 5
Detection model based on TCA.


## 5. Model Test

### 5.1. Construction of the Data Set

The core problem of this paper is that the SD and the TD do not meet the same feature distribution, so the two domains need to use different data sets. The experimental data sets are CICIDS2017 and CTU, as shown in Table1, where 10 groups of transfer learning experiments are designed.Table 1
Description of test data set.
Data setData sampleNumber of categoriesSubsetCICIDS20171600012A, B, CCTU1120011M, NCICIDS2017 contains normal traffic and the most common attack traffic at present, and gives pcap file data, in which data files are divided according to different dates, all of which are normal traffic on Monday, and attack traffic is collected from Tuesday to Friday. In this paper, it is found that if the data set contains all kinds of attacks, it is prone to negative transfer. Therefore, according to different types of attacks, CICIDS2017 data set is divided into three subsets: a subset mainly contains DDOS and DOS attacks, B subset contains PortScan, FTP-Patator, and SSH-Patator attacks, C subset contains Web attacks and botnets, and all these subsets contain normal traffic.CTU data set contains a large number of attack traffic mixed with normal traffic. Similarly, according to different types of attacks, CTU data set is divided into sub-data sets ofM and N, of which sub-data set M contains Trickster, TrickBot, and Dridex attacks, and N contains Ursnif, CoinMiner, and HTBot attacks. Similarly, these subsets also contain normal traffic.


### 5.2. Data Processing

As CICIDS2017 data set and CTU data set are both pcap files, which cannot be directly sent into the model for training, we need to preprocess the pcap files to divide the traffic packets with the same quintuple information into a flow, and mainly use Python script to analyze the remaining header and payload information of each traffic packet and vectorize it. In this way, experiments are carried out on the features that can be extracted from each flow, and the division of network traffic flow can also reflect the time sequence of traffic in NID.The processing procedure of CICIDS2017 data set and CTU data set is shown in Figure6.Figure 6
Data processing procedure.Mean value removal is to eliminate the deviation between sample features, which is realized by subtracting the mean value of all the feature values of each sample, so as to make the feature mean value zero.Range scaling is to enlarge or reduce the characteristic values of samples of different units to a reasonable range in proportion, in order to reduce the influence of the large change between different features.Normalization refers to uniformly scaling the features of different classes to a specified range, and its purpose is to unify the statistical distribution of samples to eliminate the adverse effects caused by singular samples. The most commonly used normalization method in machine learning is L1 norm, which ensures that the data are in the same order of magnitude.


### 5.3. Parameter Setting

In terms of data, the data sets used in the experiment are all network traffic data, and their distributions are different but related. Attacks in all data sets are uniformly marked as abnormal traffic. This paper conducts two-class detection of normal and abnormal traffic. 4,000 pieces of data are randomly selected from each subset of CICIDS2017 as SD and TD data sets, respectively, which is shown in Table1. Correspondingly, 3200 pieces of data are randomly selected from each subset of CTU as source and target and data set, respectively.In the aspect of model, KNN and SVM in machine learning are used as classifiers for tests [12]. In order to control the parameters of experiments, K is uniformly set to 1, the penalty factor C in SVM is equal to C = 100, and Gaussian kernel function is adopted where the performance of linear kernel is better than that of RBF and Laplacian kernel, so TCA uses linear kernel function uniformly. In order to avoid overfitting, the experiment was carried out by setting program for 10 times, and the results were obtained by averaging. The main index used to evaluate the effectiveness of traffic classification is the accuracy rate, that is, the percentage of correct traffic classification in total traffic.


### 5.4. Analysis of Results

Table2 shows the accuracy of 10 groups of transfer learning data under each model.Table 2
Test results of transfer data sets.
Data setAccuracy (%)KNNTKNNSVMTSVMA⟶M36.4349.5725.2750.81A⟶N26.9539.3747.0366.35B⟶M56.3869.6836.6056.29B⟶N27.3946.2136.1250.05C⟶M24.9048.3349.5881.97C⟶N27.9262.6529.8149.96M⟶A31.0746.9427.0542.45M⟶B47.7773.7948.9482.52M⟶C39.1457.7443.2976.75N⟶A49.4878.1657.8489.18N⟶B54.0967.4940.5369.15N⟶C36.4363.5637.7871.58Average38.1658.6239.9965.59It can be seen from the data in the table that in the anomaly detection experiments of 10 groups of cross-domain network traffic data sets, the recognition rate of the TD samples by the traditional machine learning algorithm is very low that the accuracy rate is only about 39%. The main reason is that the distribution difference between the SD traffic characteristics and the TD traffic characteristics is too large to meet the independent and identical distribution rules required by machine learning. In this case, the recognition result can hardly be used as effective reference information, and the TD cannot make use of the valuable tag information in the SD. In addition, the TCA algorithm proposed in this paper is used to adapt the traffic characteristics of SD and TD, and the marginal probability distribution and conditional probability distribution between them are reduced, which can significantly improve the accuracy of detection. Compared with the traditional machine learning algorithm, the accuracy is improved by 20%∼25%, up to 89.18%. The feature distributions of CTU and CICIDS2017 are different and do not contain the same attack types, which shows that TCA algorithm improves the detection accuracy and proves the effectiveness and feasibility of the network anomaly detection method based on TCA.In addition, it can be concluded that the accuracy of SVM classifier after being processed by TCA algorithm is higher than that of KNN, reaching 65.59%, because KNN adopted in this paper is based on Euclidean distance to calculate the difference between different eigenvalues for classification, and TCA algorithm uses the maximum mean difference to reduce the distance between SD features and TD features, which shows that the optimal separation hyperplane found by SVM model in feature space maximizes the interval between positive and negative samples in the TD, and the robustness of anomaly detection is strong.


## 5.1. Construction of the Data Set

The core problem of this paper is that the SD and the TD do not meet the same feature distribution, so the two domains need to use different data sets. The experimental data sets are CICIDS2017 and CTU, as shown in Table1, where 10 groups of transfer learning experiments are designed.Table 1
Description of test data set.
Data setData sampleNumber of categoriesSubsetCICIDS20171600012A, B, CCTU1120011M, NCICIDS2017 contains normal traffic and the most common attack traffic at present, and gives pcap file data, in which data files are divided according to different dates, all of which are normal traffic on Monday, and attack traffic is collected from Tuesday to Friday. In this paper, it is found that if the data set contains all kinds of attacks, it is prone to negative transfer. Therefore, according to different types of attacks, CICIDS2017 data set is divided into three subsets: a subset mainly contains DDOS and DOS attacks, B subset contains PortScan, FTP-Patator, and SSH-Patator attacks, C subset contains Web attacks and botnets, and all these subsets contain normal traffic.CTU data set contains a large number of attack traffic mixed with normal traffic. Similarly, according to different types of attacks, CTU data set is divided into sub-data sets ofM and N, of which sub-data set M contains Trickster, TrickBot, and Dridex attacks, and N contains Ursnif, CoinMiner, and HTBot attacks. Similarly, these subsets also contain normal traffic.


## 5.2. Data Processing

As CICIDS2017 data set and CTU data set are both pcap files, which cannot be directly sent into the model for training, we need to preprocess the pcap files to divide the traffic packets with the same quintuple information into a flow, and mainly use Python script to analyze the remaining header and payload information of each traffic packet and vectorize it. In this way, experiments are carried out on the features that can be extracted from each flow, and the division of network traffic flow can also reflect the time sequence of traffic in NID.The processing procedure of CICIDS2017 data set and CTU data set is shown in Figure6.Figure 6
Data processing procedure.Mean value removal is to eliminate the deviation between sample features, which is realized by subtracting the mean value of all the feature values of each sample, so as to make the feature mean value zero.Range scaling is to enlarge or reduce the characteristic values of samples of different units to a reasonable range in proportion, in order to reduce the influence of the large change between different features.Normalization refers to uniformly scaling the features of different classes to a specified range, and its purpose is to unify the statistical distribution of samples to eliminate the adverse effects caused by singular samples. The most commonly used normalization method in machine learning is L1 norm, which ensures that the data are in the same order of magnitude.


## 5.3. Parameter Setting

In terms of data, the data sets used in the experiment are all network traffic data, and their distributions are different but related. Attacks in all data sets are uniformly marked as abnormal traffic. This paper conducts two-class detection of normal and abnormal traffic. 4,000 pieces of data are randomly selected from each subset of CICIDS2017 as SD and TD data sets, respectively, which is shown in Table1. Correspondingly, 3200 pieces of data are randomly selected from each subset of CTU as source and target and data set, respectively.In the aspect of model, KNN and SVM in machine learning are used as classifiers for tests [12]. In order to control the parameters of experiments, K is uniformly set to 1, the penalty factor C in SVM is equal to C = 100, and Gaussian kernel function is adopted where the performance of linear kernel is better than that of RBF and Laplacian kernel, so TCA uses linear kernel function uniformly. In order to avoid overfitting, the experiment was carried out by setting program for 10 times, and the results were obtained by averaging. The main index used to evaluate the effectiveness of traffic classification is the accuracy rate, that is, the percentage of correct traffic classification in total traffic.


## 5.4. Analysis of Results

Table2 shows the accuracy of 10 groups of transfer learning data under each model.Table 2
Test results of transfer data sets.
Data setAccuracy (%)KNNTKNNSVMTSVMA⟶M36.4349.5725.2750.81A⟶N26.9539.3747.0366.35B⟶M56.3869.6836.6056.29B⟶N27.3946.2136.1250.05C⟶M24.9048.3349.5881.97C⟶N27.9262.6529.8149.96M⟶A31.0746.9427.0542.45M⟶B47.7773.7948.9482.52M⟶C39.1457.7443.2976.75N⟶A49.4878.1657.8489.18N⟶B54.0967.4940.5369.15N⟶C36.4363.5637.7871.58Average38.1658.6239.9965.59It can be seen from the data in the table that in the anomaly detection experiments of 10 groups of cross-domain network traffic data sets, the recognition rate of the TD samples by the traditional machine learning algorithm is very low that the accuracy rate is only about 39%. The main reason is that the distribution difference between the SD traffic characteristics and the TD traffic characteristics is too large to meet the independent and identical distribution rules required by machine learning. In this case, the recognition result can hardly be used as effective reference information, and the TD cannot make use of the valuable tag information in the SD. In addition, the TCA algorithm proposed in this paper is used to adapt the traffic characteristics of SD and TD, and the marginal probability distribution and conditional probability distribution between them are reduced, which can significantly improve the accuracy of detection. Compared with the traditional machine learning algorithm, the accuracy is improved by 20%∼25%, up to 89.18%. The feature distributions of CTU and CICIDS2017 are different and do not contain the same attack types, which shows that TCA algorithm improves the detection accuracy and proves the effectiveness and feasibility of the network anomaly detection method based on TCA.In addition, it can be concluded that the accuracy of SVM classifier after being processed by TCA algorithm is higher than that of KNN, reaching 65.59%, because KNN adopted in this paper is based on Euclidean distance to calculate the difference between different eigenvalues for classification, and TCA algorithm uses the maximum mean difference to reduce the distance between SD features and TD features, which shows that the optimal separation hyperplane found by SVM model in feature space maximizes the interval between positive and negative samples in the TD, and the robustness of anomaly detection is strong.


## 6. Conclusion

In this paper, the transfer learning theory is introduced into the NID system, and a NID method based on TCA is proposed, in which transfer learning does not require the SD and the TD to obey the same marginal probability distribution or conditional probability distribution. By transferring the knowledge of SD, the problem of learning in TD without or with only a bit of labeled data can be solved. In addition, the original data are used in the shared subspace to train the model with KNN and SVM classifier where the new sample traffic is detected. The results show that the TCA algorithm proposed in this paper can adapt to the characteristics of SD traffic and the TD traffic, thus significantly improving the detection accuracy. The accuracy of SVM classifier after TCA algorithm is higher than KNN, reaching 65.59%, and its robustness in abnormal detection is strong.



---

*Source: 9248853-2022-07-07.xml*