<<

& knowledge extraction

Article Multi-Layer Hidden Based Intrusion Detection System

Wondimu K. Zegeye *, Richard A. Dean and Farzad Moazzami

Department of Electrical and Computer Engineering, Morgan State University, Baltimore, MD 21251, USA; [email protected] (R.A.D.); [email protected] (F.M.) * Correspondence: [email protected]

 Received: 14 October 2018; Accepted: 12 December 2018; Published: 25 December 2018 

Abstract: The all IP nature of the next generation (5G) networks is going to open a lot of doors for new vulnerabilities which are going to be challenging in preventing the risk associated with them. Majority of these vulnerabilities might be impossible to detect with simple networking traffic monitoring tools. Intrusion Detection Systems (IDS) which rely on machine learning and artificial intelligence can significantly improve network defense against intruders. This technology can be trained to learn and identify uncommon patterns in massive volume of traffic and notify, using such as alert flags, system administrators for additional investigation. This paper proposes an IDS design which makes use of machine learning algorithms such as Hidden Markov Model (HMM) using a multi-layer approach. This approach has been developed and verified to resolve the common flaws in the application of HMM to IDS commonly referred as the curse of dimensionality. It factors a huge problem of immense dimensionality to a discrete set of manageable and reliable elements. The multi-layer approach can be expanded beyond 2 layers to capture multi-phase attacks over longer spans of time. A pyramid of HMMs can resolve disparate digital events and signatures across protocols and platforms to actionable information where lower layers identify discrete events (such as network scan) and higher layers new states which are the result of multi-phase events of the lower layers. The concepts of this novel approach have been developed but the full potential has not been demonstrated.

Keywords: Intrusion Detection System (IDS); Hidden Markov Model (HMM); multi-stage attacks

1. Introduction Intrusion Detection Systems have been the subject of a lot of research both in academia and industry in the past few decades as the interest in information security has been growing rapidly. The National Institute of Standards and Technology (NIST) defines intrusion detection as “the process of monitoring the events occurring in a computer system or network and analyzing them for signs of intrusions, defined as attempts to compromise the confidentiality, integrity, availability, or to bypass the security mechanisms of a computer or network.” A system which addresses or automates intrusion detection is referred as Intrusion Detection System (IDS) [1]. Intrusion detection systems come in different flavors and approaches. Based on their points of placement, they can be categorized into network-based intrusion detection system (NIDS) and host-based intrusion detection system (HIDS). A network intrusion detection system (NIDS) is placed at a strategic point in the network such that packets traversing a particular network link can be monitored. NIDSs monitor a given network interface by placing it in promiscuous mode. This will help the IDS in hiding its existence from network attackers while performing the task of network traffic monitoring. On the other hand, Host-based IDSs monitor and reside in individual host machines.

Mach. Learn. Knowl. Extr. 2019, 1, 265–286; doi:10.3390/make1010017 www.mdpi.com/journal/make Mach. Learn. Knowl. Extr. 2019, 1 266

HIDSs operate by monitoring and analyzing the host system internals such as operating system calls and file systems. In the same way as NIDS, it can also monitor the network interface of the host. The techniques employed by modern day IDSs to gather and analyze data are extremely diverse. However, those techniques have common basic features in their structures: a detection module which collects data that possibly contain evidence of intrusion and an analysis engine which processes this data to identify intrusive activity. Those analysis engines mainly use two techniques of analysis: anomaly detection and misuse detection. The intrinsic nature of misuse detection revolves around the use of expert system which is capable of identifying intrusions mainly based on a preordained knowledge base. Consequently, misuse structures are able to reach very high levels of accuracy in identifying even very subtle intrusions which might be represented in their knowledge base; similarly, if this expert know-how base is developed carefully, misuse systems produce a minimum number of false positives [2]. Unfortunately these architectures are less fortunate due to the fact that a misuse detection system is incapable of detecting intrusions that are not represented in its know-how base. Subtle versions of known attacks may additionally affect the evaluation if a misuse system is not always well constructed. Therefore, the efficiency of the system is highly dependent on the thorough and accurate creation of this information base, undertaking that calls for human expertise involvement, thus, the need to develop anomaly detection methods. A wide variety of strategies have been explored to detect anomalous events from normal ones including neural networks, statistical modeling and Hidden Markov Models to name a few. Those approaches rely on the same principle. At first, a baseline model that is a representative of normal system behavior against which anomalous events can be distinguished is established. When an event indicates anomalous activity, as compared with the baseline, it is considered as malicious. This system characterization can be used to identify anomalous traffic from normal traffic. One of the very attractive features of anomaly based intrusion detection systems is their capability to identify previously unseen attacks. The baseline model in this case is usually automated and it does not require both human interference and the knowledge base. The aftermath of this approach is that the detection system may fail to detect even well-known attacks if they are crafted not to be substantially different from the normal behavior established by the system. Currently, more than fifty percent of the web traffic is encrypted-both normal and malicious. The volume of encrypted traffic is expanding even more which creates confusions and challenges for security teams trying to monitor and identify malicious network traffic. The main goal of encryption is to enhance network security but at the same time it provides intruders the power to hide command-and-control (C2) activity giving them enough time to launch attack and cause damage. To keep up with the intruders, security teams need to include additional automation and modern tools that are developed using machine learning and artificial intelligence to supplement threat detection, prevention and remediation [3]. More enterprises are now exploring machine learning and artificial intelligence to prevail over the effect of encryption and decrease adversaries’ time. These advanced concepts have the capability to keep up their performance without humans having to clarify precisely the way to accomplish the tasks that they are provided. Unusual patterns of web traffic that can indicate malicious activity can be automatically detected as these advanced systems can, overtime, “learn” by themselves. To automatically detect “known-known” threats, the types of attacks that have been known previously, machine learning plays a significant role. But its main advantage in monitoring encrypted web traffic is due to the fact that it is capable of detecting “known-unknown” threats (previously unknown distinct form of known threats, malware subdivision, or similar new threats) and “unknown-unknown” (net-new malware) threats. Those technologies automatically alert potential attacks to network administrators as they can learn to identify unusual patterns in massive volumes of encrypted web traffic. Mach. Learn. Knowl. Extr. 2019, 1 267

Those automatic alerts are very important in organizations where there is a lack of knowledgeable personnel in the enhancement of security defenses. Intelligent and automated tools using machine learning and artificial intelligence can help security teams fill the gaps in skills and resources, making them more practical at recognizing and responding to both well-known and prominent threats. Several techniques of artificial intelligence (AI) have been explored in the path towards developing IDSs, for example, fuzzy logic, artificial neural networks (ANNs) and genetic algorithms (GA). In addition, hybrid intelligent IDSs, such as evolutionary neural network (ENN) and evolutionary fuzzy neural networks (EFuNN)—based IDSs, are also used. This work proposes the potential application of the Hidden Markov Model (HMM) for intrusion detection which is capable of providing finer-grained characterization of network traffic using a multi-layer approach. The current implementations of HMMs for IDS are mainly based on a single HMM which will be trained for any incoming network traffic to identify anomalous and normal traffic during testing. Other HMM based IDS implementations rely on multi HMM profiles where each of the HMMs are trained for a specific application type traffic and posterior probabilities are used to select network applications using only packet-level information that remain unchanged and observable after encryption such as packet size and packet arrival time [4]. This approach, even if it factors based on application layer traffic, it considers a limited number of features and is unable to detect multistage attacks which can be crafted to look like normal traffic. Similarly, the work in Reference [5] applied several pre-processing techniques on the dataset considered to implement a multi class system (MCS) HMM based IDS. Besides to the capability of multi-layer HMM design to detect multi-stage attacks, the IDS data analysis engine of the approach proposed here, on the other hand, uses several features where a dimension reduction technique will be applied to extract only important features. A single layer HMM which attempts to detect multi-stage attacks from a dataset made up of several steps of an attack trace is implemented in Reference [6]. Recent HMM based implementations, such as in Reference [7], are based on a database of HMM templates corresponding to each attack and eventually used to detect multiple multi-stage attacks. HMMs use statistical learning algorithms that suffer in cost exponentially as the volume of data grows. This aspect is commonly referred as the curse of dimensionality [8]. The HMMs tend to fail, more often than not, on a large dimension state space. Considering a single HMM based IDS, as the incoming network traffic will have a large hidden state space, it will fall a victim to this curse of dimensionality. The solution to those problems involves the principle of decomposition. Decomposition technique [9] comprises of the following steps: the algorithm of decomposition is applied to lower levels to construct each individual HMMs, representing partial solutions, which will be combined to form the final global solution. The multi-layer approach proposed in this work has been developed and verified to resolve the common flaws in the application of HMM to IDS commonly referred as the curse of dimensionality. It factors a huge problem of immense dimensionality to a discrete set of manageable and reliable elements. The multi-layer approach can be expanded beyond 2 layers to capture multi-phase attacks over longer spans of time. A pyramid of HMMs can resolve disparate digital events and signatures across protocols and platforms to actionable information where lower layers identify discrete events (such as network scan) and higher layers new states which are the result of multi-phase events of the lower layers. The concepts of this novel approach have been developed but the full potential has not been demonstrated as will be described in the next sections.

2. Design Approach A challenge in applying the Markov model to intrusion detection systems is the lack of a standard method for the translation of the observed network packet data into meaningful Markov model. Mach. Learn. Knowl. Extr. 2019, 1 268

The first step towards building an IDS based on multiple layers of Hidden Markov Models involves processing network traffic into meaningful observations. The IDS designed in this work is as specified in flow chart of Figure1. It starts by data processing of the captured Wireshark file using feature generation, among those generated features or creationMach. Learn. of Knowl. new Extr. features 2018, 2, byx FOR combining PEER REVIEW the generated features, use machine learning4 algorithm of 22 for dimension reduction and finally, apply vector quantization techniques to create meaningful learning algorithm for dimension reduction and finally, apply vector quantization techniques to observations for the HMMs. The details of the layered HMM design is discussed in Section 2.5 create meaningful observations for the HMMs. The details of the layered HMM design is discussed and thein Section corresponding 2.5 and themodel corresponding structure model is as structure shown in is Figureas shown 3. in Figure 3.

FigureFigure 1. 1.Flow Flow Chart Chart of of thethe IDS model including including the the data data processing. processing.

2.1. CICIDS20172.1. CICIDS2017 Data Data Processing Processing DatasetsDatasets such such as DARPA98-99(Lincoln as DARPA98-99(Lincoln Laboratory Laboratory 1998–1999), 1998–19 KDD’9999), KDD’99 (University (University of California, of IrvineCalifornia, 1998–1999), Irvine DEFCON 1998–1999), (The DEFCON Shmoo Group, (The Shmoo 2000–2002) Group, UMASS 2000–2002) (University UMASS (University of Massachusetts of 2011),Massachusetts ISC2012 (University 2011), ISC2012 of New (University Brunswick of New 2012) Brunswick and ADFA’13 2012) (Universityand ADFA’13 of (UniversityNew South of Wales New South Wales 2013), to name a few, have been used by several researchers to validate their IDS’s 2013), to name a few, have been used by several researchers to validate their IDS’s designs and designs and approaches. Those datasets have shortcomings associated with them. For example, approaches.DARPA98 Those-99 and datasets KDD’99 haveare outdated shortcomings and unreliable associated as several with flows them. are For redundant; example, NSL DARPA98-99-KDD and KDD’99has been areused outdated to replace and KDD’99 unreliable by removing as several the flowssignificant are redundant;redundancy NSL-KDD. The work in has Reference been used to replace[10] KDD’99 further by analyzed removing the the KDD’9 significant9 and presented redundancy. new The proofs work to in these Reference existing [ 10 inconsistencies.] further analyzed the KDD’99CAIDA and (Center presented of Applied new proofs Internet to Data these Analysis existing inconsistencies.2002–2016) traffic CAIDA payloads (Center are heavily of Applied Internetanonymized. Data Analysis ADFA’13 2002–2016) lacks attack traffic diversity payloads and variety. are heavily Besides anonymized. to these popular ADFA’13 datasets lacksamong attack diversityvarious and re variety.searchers, Besides several toothers these are popular also explored datasets in Reference among various [11]. researchers, several others are also exploredMost inof Referencethe datasets [ 11are]. also simulate attacks which are multi-stage. The CICIDS2017 dataset is designed to cover what are commonly referred as the eleven criteria for IDS dataset evaluation Most of the datasets are also simulate attacks which are multi-stage. The CICIDS2017 dataset framework (Network, traffic, Label, Interaction, capture, Protocols, Attack diversity, anonymization, is designed to cover what are commonly referred as the eleven criteria for IDS dataset evaluation heterogeneity, features and metadata). The details of this dataset compared to the commonly frameworkavailable (Network, IDS evaluation traffic, datasets Label, is Interaction,presented in capture,Reference Protocols, [12]. Attack diversity, anonymization, heterogeneity,For testing features the andmodeled metadata). IDS in this The work, details a ofdataset this datasetis prepared compared from the to CICIDS2017 the commonly dataset. available IDS evaluationThis dataset datasets covers eleven is presented criteria which in Reference are necessary [12]. in building a reliable benchmark dataset. It containsFor testing very the common modeled attacks IDS such in thisas XSS, work, Port ascan, dataset Infiltration, is prepared Brute Force, from theSQL CICIDS2017Injection, Botnet dataset. ThisDoS dataset and coversDDoS. The eleven dataset criteria is made which up of are 81 necessaryfeatures including in building the label a reliable and it is benchmark publicly available dataset. It in Canadian Institute for Cybersecurity website [13]. Some of these features are directly extracted

Mach. Learn. Knowl. Extr. 2019, 1 269 contains very common attacks such as XSS, Port scan, Infiltration, Brute Force, SQL Injection, Botnet DoS and DDoS. The dataset is made up of 81 features including the label and it is publicly available in Canadian Institute for Cybersecurity website [13]. Some of these features are directly extracted while others are calculated for both normal (benign) and anomalous flows using the CICFlowMeter [14]. The CICIDS2017 dataset comprises 3.1 million flow records and it covers five days. It includes the following labeled attack types: Benign, DoS Hulk, Port Scan, DDoS, DoS, FTP Patator, SSH Patator, DoS Slow Loris, DoS Slow HTTP Test, Botnet, Web Attack: Brute Force, Web Attack: Infiltration, Web Attack: SQL Injection and Heartbleed. The portion of the “Thursday-WorkingHours-Morning-webattack” is used to create the training and testing dataset which constitutes “BENIGN”, “SSH Patator” and “Web Attack-Brute Force” traffic.

2.2. Feature Selection and Creation Feature selection involves choosing a subset of features from the initial available features whereas feature creation is a process of constructing new features and it is usually performed after feature selection process. Feature selection takes a subset of features (M) from the original set of features (N) where M < N. To build a robust and high performance IDS, the features created or constructed from the subset of selected features could follow a knowledge-based approach. Other approaches which can be applied to construct new features are data-driven, hypothesis-driven and hybrid [15,16]. From Features discarded include Source port. This is due to the fact that as it is part of the Categorical encoding is applied on the following features (Flow_ID, Source_IP, Destination_IP), resulting in numerical values. In addition, a new feature (label) which identifies the traffic type such as BENIGN, SSH-patator and web-attack-bruteforce is added. The values corresponding to this new feature are also categorically encoded.

2.3. Feature Extraction/Dimension Reduction On the other hand, dimension reduction is one form of transformation whereby a new set of features is extracted. This feature extraction process extracts a set of new features from the initial features through some functional mapping [17]. Feature extraction, also known as dimension reduction, is applied after feature selection and feature creation procedures on the original set of features. Its goal is to extract a set of new features through some functional mapping. If we initially have n features (or attributes), A1, A2, ... , An, after feature selection and creation, feature extraction results in a new set of features, B1, B2, ... , Bm (m < n) where Bi = Fi(A1, A2,..., An) and Fi is a mapping function. PCA is a classic technique which is used to compute a linear transformation by mapping data from a high dimensional space to a lower dimension. The original n features are replaced by another set of m features that are computed from a linear combination of these initial features. Principal Component Analysis is used to compute a linear transformation by mapping data from a high dimensional space to a lower dimension. The first principal component contributes the highest variance in the original dataset and so on. Therefore, in the dimension reduction process, the last few components can be discarded as it only results in minimal loss of the information value [18]. The main goals of PCA:

1. Extract the maximum variation in the data. 2. Reduce the size of the data by keeping only the significant information. 3. Make the representation of the data simple. 4. Analyze the structure of the variables (features) and observations.

Generally speaking, PCA provides a framework for minimizing data dimensionality by identifying principal components, linear combinations of variables, which represent the maximum variation in the data. Principal axes linearly fit the original data so the first principal axis minimizes the Mach. Learn. Knowl. Extr. 2019, 1 270 sum of squares for all observational values and maximally reduces residual variation. Each subsequent principal axis maximally accounts for variation in residual data and acts as the line of best fit directionally orthogonal to previously defined axes. Principal components represent the correlation betweenMach. Learn. variables Knowl. Extr. and 2018 the, 2,corresponding x FOR PEER REVIEW principal axes. Conceptually, PCA is a greedy algorithm6 of 22 fitting each axis to the data while conditioning upon all previous axes definitions. Principal components projectalgorithm the original fitting data each onto axis these to the axes, data where while these conditioning axes are ordered upon such all thatprevious Principal axes Component definitions. 1Principal (PC1) accounts components for the mostproject variation, the original followed data byontoPC these2,..., axes,PCp forwherep variables these axes (dimensions). are ordered such

thatSteps Principal to compute Component PCA using1 ( Eigen) accounts Value for Decomposition the most variation, (EVD): followed by , … , for variables (dimensions). 1. From each of the dimensions subtract the . Steps to compute PCA using Eigen Value Decomposition (EVD): 2. Determine the . 3. Determine1. From each the of eigenvalues the dimensions and eigenvectors subtract the ofmean. the calculated covariance matrix. 4. Reduce2. Determine dimensionality the covariance and construct matrix. a feature vector. 5. Determine3. Determine the the new eigenvalues data. and eigenvectors of the calculated covariance matrix. 4. Reduce dimensionality and construct a feature vector. The5. Determine PCA procedure the new used data. applies Singular Value Decomposition (SVD) instead of Eigenvalue Decomposition (EVD) [19]. SVD is numerically more stable as it avoids the computation of the The PCA procedure used applies Singular Value Decomposition (SVD) instead of Eigenvalue covariance matrix which is an expensive operation. Decomposition (EVD) [19]. SVD is numerically more stable as it avoids the computation of the Singularcovariance Value matrix Decomposition which is an expensive (SVD) for operation Principal. Component Analysis (PCA) SingularAny matrix Value X Decomposition of dimension N (SVD)× d can for be Principal uniquely Component written as X Analysis= U × Σ (×PCA)VT Where Any matrix X of dimension N x d can be uniquely written as = × × •Wherer is the rank of matrix X (i.e., the number of linearly independent vectors in the matrix) • Ur isis athe column- rank of orthonormal matrix X (i.e. matrix, the number of dimension of linearlyN × independentd vectors in the matrix) • ∑Uis is aa diagonalcolumn- orthonormal matrix of dimension matrix of dimensionN × d where ×σi’s (the singular values) are sorted in  descending∑ is a diagonal order across matrix the of diagonal.dimension × where σi ‘s (the singular values) are sorted in • Vdescending is a column- order orthonormal across the matrix diagonal. of dimension d × d.  V is a column- orthonormal matrix of dimension × . Given a data matrix X, the PCA computation using SVD is as follows Given a data matrix X, the PCA computation using SVD is as follows • For XT X, a rank r (N ≥ d ⇒ r ≤ d), square, symmetric N × N matrix  For , a rank ( ≥ ⇒ ≤ ), square, symmetric × matrix

. {{,vˆ1,,vˆ…2,...,, } visˆr }theis set the of orthonormal set of orthonormal × Eigenvectorsd × 1 Eigenvectors with Eigenvalues with { Eigenvalues, , … , } {λ1, λ2,..., λr}  The principal components of are the eigenvectors of • The principal components of X are the eigenvectors of XT X  =√ are positive real and termed singular values • σ = λ are positive real and termed singular values  i{, ,i… , } is the set of orthonormal × vectors defined by • {uˆ1, uˆ2,..., uˆr} is the set of orthonormal N × 1 vectors defined by . = . uˆ ==1Xvˆ ‖ ‖ = i σi (ithe “value” form of SVD) where  ∑ is X×vˆi= andσiuˆ idiagonal(the “value” form of SVD) where kXvˆik = σi • .∑ is Nσi ×ared calledand diagonal singular values of . It is assumed that σ1 ≥ σ2 ≥ … ≥ ≥ 0 (rank ordered). For N > (r = d), the bottom N-r rows of ∑ are all zeros which will be removed and the first r rows σ are called singular values of X . It is assumed that σ ≥ σ ≥ ... ≥ σ ≥ 0 (rank ordered). of ∑ and thei first r columns of U will be kept which results in the1 decomposition2 r shown in Figure 2. For N > (r = d), the bottom N-r rows of ∑ are all zeros which will be removed and the first r rows of ∑ and the first r columns of U will be kept which results in the decomposition shown in Figure2. PCA and SVD relation

T 1 T Let X = UΣV be the SVD of matrix X and C = N−1 X X be its covariance matrix of dimension d x d. The Eigenvalues of C are the same as the right singular vectors of X.

Figure 2. Decomposition of matrix X.

PCA and SVD relation Let = be the SVD of matrix X and = be its covariance matrix of dimension d x d. The Eigenvalues of C are the same as the right singular vectors of X.

Mach. Learn. Knowl. Extr. 2018, 2, x FOR PEER REVIEW 6 of 22

algorithm fitting each axis to the data while conditioning upon all previous axes definitions. Principal components project the original data onto these axes, where these axes are ordered such

that Principal Component 1 () accounts for the most variation, followed by , … , for variables (dimensions). Steps to compute PCA using Eigen Value Decomposition (EVD): 1. From each of the dimensions subtract the mean. 2. Determine the covariance matrix. 3. Determine the eigenvalues and eigenvectors of the calculated covariance matrix. Mach. Learn. Knowl. Extr. 2019, 1 271 4. Reduce dimensionality and construct a feature vector. 5. Determine the new data. ThisThe can PCA be shown procedure with used the followingapplies Singular proof: Value Decomposition (SVD) instead of Eigenvalue Decomposition (EVD) [19]. SVD is numerically more stable as it avoids the computation of the T T T T 2 T covariance matrix which isX an Xexpensive= VΣU operationUΣV =. VΣΣV = VΣ V (1)

Singular Value Decomposition (SVD) for PrincipalΣ2 Component Analysis (PCA) C = V VT (2) Any matrix X of dimension N x d can be uniquelyN − 1 written as = × × Where As C is symmetric, hence C = VΛVT. As a result, the eigenvectors of the covariance matrix are the same as ther is matrixthe rankV of(right matrix singular X (i.e., the vectors) number andof linearly the eigenvalues independent of vectorsC can in be the determined matrix) from the 2  U is a column-σ orthonormalt matrix of dimension × singular values λi = N−1  ∑ is a diagonal matrix of dimension × where σi ‘s (the singular values) are sorted in PCA using EVD and SVD can be summarized as follows: descending order across the diagonal. = Objective V is a: column project- orthonormal the original matrix data matrixof dimension X using × the . largest m principal components, V [v1,..., vm]. Given a data matrix X, the PCA computation using SVD is as follows 1. Zero For mean the, a rank columns ( of≥ X. ⇒ ≤ ), square, symmetric × matrix 2. Apply PCA and SVD to find the principal components of X. . {, , … , } is the set of orthonormal × Eigenvectors with Eigenvalues {, , … , } PCA: The principal components of are the eigenvectors of

 = are positive real and termed singular values a. Determine the covariance matrix, C = 1 XT X.  {, , … , } is the set of orthonormal N−×1 vectors defined by b. V corresponds to the Eigenvectors of C. . = SVD: . = (the “value” form of SVD) where ‖‖ = a.  Determine∑ is × the and SVD diagonal of X = UΣVT . σi are called singular values of . It is assumed that σ1 ≥ σ2 ≥ … ≥ ≥ 0 (rank ordered). b. V corresponds to the right singular vectors. For N > (r = d), the bottom N-r rows of ∑ are all zeros which will be removed and the first r rows 3. Projectof ∑ and the the data first inr columns an m dimensional of U will be space:kept whichY = XVresults in the decomposition shown in Figure 2.

FigureFigure 2. 2.Decomposition Decomposition of of matrix matrix X.X.

ToPCA perform and SVD dimension relation reduction and form a feature vector using PCA, order the eigenvalues from the highestLet = to lowest be the by SVD value. of matrix This ordering X and = places the be components its covariance in matrix order of dimension significance to the varianced x d. The of Eigenvalues the original of C data are the matrix. same Thenas the right we can singular discard vectors components of X. of less significance. If a number of eigenvalues are small, we can keep most of the information we need and loss a little or noise. We can reduce the dimension of the original data. E.g. we have data of d dimensions and we choose only the first r eigenvectors.

∑r λ λ + λ + ... + λ i=1 i = 1 2 r (3) d λ + λ + ... + λ + ... + λ ∑i=1 λi 1 2 r d

Feature Vector = (λ1 λ2 λ3 ... λr) (4) Since each PC is orthogonal, each component independently accounts for data variability and the Percent of Total Variation Explained (PTV) is cumulative. PCA offers as many principal components as variables in order to explain all variability in the data. However, only a subset of these principal components is notably informative. Since variability is shifted into leading PCs, many of the Mach. Learn. Knowl. Extr. 2019, 1 272 remaining PCs account for little variation and can be disregarded to retain maximal variability with reduced dimensionality. For example, if 99% total variation should be retained in the model for d dimensional data, the first r principal components should be kept such that

∑r λ PTV = k=1 k ≥ d 0.99 ∑k=1 λk

PTV acts as the signal to noise ratio, which flattens with additional components. Typically, the number of informative components r is chosen using one of three methods: (1) Kaiser’s eigenvalue > 1; (2) Cattell’s scree plot; or (3) Bartlett test of sphericity. The amount of variation in redundant data decreases from the first principal component onwards. There are several methods to compute the cut off value for retaining the sufficient number of principal components out of all p components. In this work, we use the Cattell’s scree plot, which plots the eigenvalues in decreasing order [20]. The number of principal components to be kept is determined by the elbow where the curve becomes asymptotic and additional components provide little information. Another method is the Kaiser criterion Kaiser [21] which retains only factors with eigenvalues >1.

2.4. Vector Quantization Vector quantization (VQ) historically has been used in signal representation to produce feature vector sequence. One of the applications of K- is vector quantization, thus terminologies used in VQ are commonly applied. For example, the “code book” represents the set of cluster centroids and “code words” represent the individual cluster centroids. The codebook maps the cluster indexes, also known as “code,” to the centroids. A basic VQ can be achieved using K-Means clustering with a goal of finding encoding of vectors which minimizes the expected distortion.

2.4.1. Normalization Before applying VQ on the data matrix resulting from the PCA, the normalization process is applied on the original data matrix preceding the PCA steps. Normalization is helpful in generating effective results as it standardizes the features of the dataset by giving them equal weights. In doing so, noisy or redundant objects will be removed resulting in a dataset which is more reliable and viable, it improves the accuracy. Normalization can be performed using several methods such as Min-Max, Z-Score and Decimal Scaling, to name a few. In a dataset, such as the one used in this work, where among attributes there is a high degree of variation the utilization of another type of normalization known as log-normalization is very convenient [22]. The notations and steps for applying this normalization are described below. Notation:

xij—the initial value in row i and column j of the data matrix bij—the adjusted value which replaces xij The transformation below is a generalized procedure that (a) tends to preserve the original order of magnitudes in the data and (b) results in values of zero when the initial value was zero. Given: Min(x) is the smallest non-zero value in the data Int(x) is a function that truncates x to an integer by dropping digits after decimal point c = order of magnitude constant = Int(log(Min(x)) d = decimal constant = log−1(c) Then the transformation is  bij = log xij + d − c Mach. Learn. Knowl. Extr. 2019, 1 273

A small number must be added to all data points if the dataset contains zeros before applying the log-transformation. For a data set where the smallest non-zero value is 1, the above transformation will be simplified to  bij = log xij + 1

2.4.2. Clustering Once the PCA procedure is applied to the initial data, it results in the mapping of the data to a new feature space using the principal components. In the newly constructed feature space, VQ (clustering) is achieved by applying K-Means algorithm. K-Means objective function [23]:

• Let µ1 ,... µk be the K cluster centroid (means) • Let rnk ∈ {0, 1} denotes whether point xn belongs to cluster k. • It minimizes the total sum of distances of each points from their cluster centers (total distortion)

N K 2 J(µ, r) = ∑ ∑ rnkkxn − µkk n=1 k=1

The steps followed by this algorithm are as follows:

D 1. Input: N examples {x1, x2,..., xn}; (xn ∈ R ) 2. Initialization: K cluster centers µ1 ,... µk. K can be initialized:

• Randomly initialized anywhere in RD or • Randomly take any K examples as the initial cluster centers.

3. Iteration:

• Assign each of example xn to its closest cluster center

 2 Ck = n : k = arg minkxn − µk (Ck corresponds to the set of examples closest to µk)

• Re-calculate the new cluster centers µk (mean/centroid of the set Ck)

1 µk = ∑ xn |Ck| n∈Ck

• Repeat until convergence is achieved: A simple convergence criteria can be considered as the cluster centers do not move anymore.

To put it in a nut shell, K-Means Clustering is an algorithm which attempts to find groups in a given number of observations or data. Each element of the vector µ refers to the sample mean of its corresponding cluster, x refers to each of the examples and C contains the assigned class labels [24]. The optimal number of clusters is determined using the Elbow method which is among the many different heuristics for choosing a suitable K. The way it works is we run the algorithm using different values of K and plot the heterogeneity. It operates in such a way that, for different values of K the heterogeneity is plotted. In general, this measurement decreases when the value of K increases since the size of the clusters decreases. The point where this measurement starts to flat out (elbow on the plot) corresponds to the optimal value of K [25]. Mach. Learn. Knowl. Extr. 2019, 1 274

2.5. Design of Layered Hidden Markov Model (LHMM) based Intrusion Detection System (IDS) This section discusses the novel layered HMM which is designed to detect multi-stage attacks. This layering technique can be further extended beyond the specific structure (Figure3) which is simulated and discussed in this work.

2.5.1. Problem Statement Summary and Preliminaries (1) The problem space is decomposed into two separate layers of HMMs. (2) Each layer constitutes two levels: the observation data is used to train the HMMs and estimate the model’s parameters at the first level of each layer and those parameters are used to find the most probable sequence of hidden states at the second level of the same layer. (3) The probable observable state sequences from each of the HMMs are used to construct the training data at Layer 2. It will be used for training the upper layer HMM which will be able to use the information from the lower layer HMMs to learn new patterns which are not possibly recognized by the lower layer HMMs.

2.5.2. Model Structure of HMM An HMM is a double . In other words, it represents two related stochastic process with the underlying stochastic process that is not necessarily observable but can be observed by another set of stochastic processes that produces the sequence of observations [26,27]. A typical notation for a discrete-observation HMM is

T = observation sequence length N = number of states in the model M = number of distinct observation symbols per state

Q = {q1, q2, ..., qN } = distinct “hidden” states of the Markov process V = {v1, v2, ..., vM } = set of observation symbols per state S = {s1, s2, ..., sN } = the individual states

It is specified by a set of parameters (A, B, Π) and each of the parameters is described below. At time t, ot and qt denote the observation and state symbols respectively.

1. The prior (initial state) distribution Π = Πi where Πi = P(q1 = si) are the probabilities of si being the first state in a state sequence.   2. The probability of state transition matrix A = aij where aij = P qt+1 = sj qt = si , is the probability of going from state si to state sj.

3. The observation (emission) transition probability distribution B = {bik} where bi(k) =  P ot = vj qt = si is the probability of observing state sk given qt = si.

Conventionally, the HMM model is represented by λ = (A, B, Π) . Given an HMM model, there are three problems to solve. One of the problems, also known as model training, is adjusting the model parameters to maximize the probability of the observation given a particular model and this is achieved using Baum-Welch algorithm which is a type of Expectation Maximization (EM) [28,29]. This procedure computes the maximum-likelihood estimates, local maxima, of the HMM model parameters (A, B, Π) using the forward and backward algorithms. In another word, for HMM models, λ1, λ2, ... , λn and a given sequence of observations, O = o1, o2, ... , ot, we choose λ = (A, B, Π) such that P(O|λi), i = 1, 2, . . . , n is locally maximized.

2.5.3. Model Structure of Two-Layered HMM (LHMM)

1. At Layer 1, we have HMM1, HMM2, ... , HMMp with their corresponding number of hidden states S1,S2,...,Sp. Mach. Learn. Knowl. Extr. 2019, 1 275

2. Considering the same time granularity (t = T) of each of the HMMs,

• The observation sequence for each of the HMMs are given as:

T 1 2 T T 1 2 T T 1 2 T O1 = {O1 ,O1 ,...,O1 }, O2 = {O2 ,O2 ,...,O2 }, . . . , Op = {Op ,Op ,...,Op }

• The probable sequence of states for each of the HMMs are given as:

T 1 2 T 1 2 T 1 2 T Q1 = {q1 , q1 , . . . , q1 }, {q2 , q2 , . . . , q2 }, . . . , {qp , qp , . . . , qp }

3. A new feature vector is constructed from the Layer 1 HMMs probable sequence of states. This statistical feature can be considered as a new data matrix where VQ can be applied and a new sequence of observations will be created from the Layer 2 HMM.

The feature vector is constructed as follows:

 i  q1  .  fi =  . , ∀i = 1, 2, . . . , p (5) i qT

F = f f f  ∀ = Mach. Learn. Knowl. Extr. 2018, 2, x FOR PEER1 REVIEW, 2,... j , j 1, 2, . . . , p 11 of 22 (6)

T 1 2 T HMM1 (A, B, Π O1 ={ O1 , O1 , …, O1 } )

T 1 2 T HMM2 (A, B, Π) HMM (A, B, Π) O2 ={ O2 , O2 , …, O2 } 𝐹 VQ

HMM (A, B, Π) T 1 2 T p Op ={ Op , Op , …, Op } Estimated

Figure 3. Multi-Layered HMM (LHMM) model structure. Figure 3. Multi-Layered HMM (LHMM) model structure. 2.5.4. Learning in LHMM 2.5.4. Learning in LHMM The modelsThe models at Layer at Layer 1 and 1 and Layer Layer 2 2 are are trained trained independently independently to HMM model to HMM at Layer model 2. Every at Layer 2. Every HMMHMM in in each each layerlayer constitutes constitutes two twolevels levels where th wheree first level the firstdetermines level model determines parameters model and the parameters and the secondsecond level level findsfinds the the most most probable probable sequence sequence of states. of states. At the Atfirst the level first of levelLayer of1, Layergiven the 1, given the discrete timediscrete sequence time sequence of observations, of observations, the the Baum-Welch Baum-Welch algorithm algorithm is used is used for training for training the outputs the of outputs of probable sequences. At the second level of Layer 1 and Layer 2, the is used for probable sequences.finding the probable At thesecond sequences level based of on Layer the output 1 and of Layer learned 2, theparameters Viterbi from algorithm first level is of used same for finding the probablelayer. sequences based on the output of learned parameters from first level of same layer. 1. Learning at Layer 1 1. Learning at Layer 1 • Vector Quantization technique using K-Means Clustering applied on the training dataset. • • The Baum-Welch, an Expectation Maximization (EM), is used to compute the maximum Vectorlog-likelihood Quantization estimates technique of the usingHMM model K-Means parameters Clustering (A, B, Π applied). on the training dataset. • The Baum-Welch, an Expectation Maximization (EM), is used to compute the maximum 2. Learning at Layer 2 log-likelihood estimates of the HMM model parameters (A, B, Π). • Vector Quantization technique using K-Means Clustering, as defined in subsection 2.4.2, is 2. Learning atapplied Layer on 2 the training dataset. Here the training dataset corresponds to matrix F in Equation (6). • As we have a single HMM at Layer 2, the Baum-Welch method is used to compute the • Vector Quantization technique using K-Means Clustering, as defined in Section 2.4.2, is applied maximum log-likelihood estimates of the HMM model parameters (A, B, Π). on the training dataset. Here the training dataset corresponds to matrix F in Equation (6). For the simulation of the LHMM, the two HMMs considered at the lower layer are HTTP and • AsSSH wetraffic. have a single HMM at Layer 2, the Baum-Welch method is used to compute the maximum log-likelihood estimates of the HMM model parameters (A, B, Π). 3. Results This section discusses the results of the data processing for the modeled IDS: the dataset analysis using PCA for dimension reduction, K-Means clustering for vector quantization and finally the results of the LHMM.

3.1. Data Processing Results 1. HTTP traffic PCA Analysis The results of HTTP traffic PCA analysis are demonstrated below. Figure 4 shows the scree plot of the dimensions with respect to percentage of explained variance and eigenvalues. The elbow method can be used to determine the number of dimensions to be retained. Equivalently, the cumulative percent of variance with respect to the number of dimensions, as shown in Table 1, can be used to determine the number of dimensions to be retained.

Mach. Learn. Knowl. Extr. 2019, 1 276

For the simulation of the LHMM, the two HMMs considered at the lower layer are HTTP and SSH traffic.

3. Results This section discusses the results of the data processing for the modeled IDS: the dataset analysis using PCA for dimension reduction, K-Means clustering for vector quantization and finally the results of the LHMM.

3.1. Data Processing Results 1. HTTP traffic PCA Analysis The results of HTTP traffic PCA analysis are demonstrated below. Figure4 shows the scree plot of the dimensions with respect to percentage of explained variance and eigenvalues. The elbow method can be used to determine the number of dimensions to be retained. Equivalently, the cumulative percentMach. Learn. of Knowl. variance Extr. with2018, 2 respect, x FOR PEER to the REVIEW number of dimensions, as shown in Table1, can be used12 of to 22 determine the number of dimensions to be retained.

(a) (b)

Figure 4. (a) Scree Plot of the percentage of explained variance; (b) Scree plot of eigenvalues. Figure 4. (a) Scree Plot of the percentage of explained variance; (b) Scree plot of eigenvalues. Table 1. Principal components with their variance contribution.

Table Eigenvalue1. Principal components Percent with of Variancetheir variance Cumulative contribution. Percent of Variance × 2 × 1 Dim.1 Eigenvalue4.762758 10Percent of Variance5.826067 10 Cumulative Percent58.26067 of Variance Dim.2 2.011200 × 102 2.460210 × 101 82.86276 Dim.1Dim.3 4.7627587.160326 × 102 × 101 5.826067 × 108.7589041 58.26067 91.62167 1 Dim.2Dim.4 2.0112002.027640 × 102 × 10 2.460210 × 102.4803201 82.86276 94.10199 Dim.5 1.437619 × 101 1.758575 95.86056 1 Dim.3Dim.6 7.1603261.010701 × 10 × 101 8.7589041.236345 91.62167 97.09691 Dim.4Dim.7 2.027640 × 4.111222 101 2.4803205.029072 × 10−1 94.1019997.59981 Dim.8 4.057777 × −1 98.09618 Dim.5 1.437619 × 101 1.7585754.963695 10 95.86056 Dim.9 2.812110 3.439927 × 10−1 98.44018 Dim.6Dim.10 1.010701 × 2.672606 101 1.2363453.269278 × 10−1 97.0969198.7671 −1 Dim.7Dim.11 4.111222 1.433143 5.0290721.753099 × 10−1 × 10 97.5998198.94241 Dim.12 1.283170 1.569643 × 10−1 99.09938 −1 Dim.8Dim.13 4.057777 1.226318 4.9636951.500099 × 10 × 10−1 98.0961899.24939 Dim.9Dim.14 2.8121109.864789 × 10−1 3.4399271.206715 × 10−1 × 10−1 98.4401899.37006 × −1 × −2 Dim.10Dim.15 2.6726068.110305 10 3.2692789.920970 × 10−1 10 98.767199.46927 Dim.16 7.242188 × 10−1 8.859041 × 10−2 99.55786 Dim.11Dim.17 1.4331436.931104 × 10−1 1.7530998.478506 × 10−1 × 10−2 98.9424199.64264 − − Dim.12Dim.18 1.2831706.044243 × 10 1 1.5696437.393649 × 10−1 × 10 2 99.0993899.71658 Dim.19 4.243713 × 10−1 5.191142 × 10−2 99.76849 Dim.13 1.226318 1.500099 × 10−1 99.24939 Dim.14 9.864789 × 10−1 1.206715 × 10−1 99.37006 For theDim.15 HTTP 8.110305 traffic 8 principal× 10−1 components9.920970 × 10 which−2 correspond to99.46927 98.09618% of the explained variance areDim.16 selected 7.242188 from Table × 101−1. Those8.859041 selected × 810 PCs−2 and the first 6 (head)99.55786 out of the total number of featuresDim.17 are shown 6.931104 in Table × 210. Each−1 PC8.478506 is constructed × 10−2 from a linear combination99.64264 of the total features and theirDim.18 multiplying 6.044243 coefficients × 10−1 specified7.393649 thetable. × 10−2 99.71658 Dim.19 4.243713 × 10−1 5.191142 × 10−2 99.76849

Mach. Learn. Knowl. Extr. 2019, 1 277

Table 2. The selected 8 Principal components and head (6 of the original features only displayed here).

PC1 PC2 PC3 PC4 PC5 PC6 PC7 PC8 Flow_ID 7.955283 × 10−5 1.457065 × 10−2 1.644281 × 10−3 3.287887 × 10−1 5.998037 × 10−2 9.81543 × 10−2 2.131072 × 10−1 3.108175 × 10−1 Source_IP 7.387470 × 10−3 4.617471 × 10−2 4.837233 × 10−3 2.641242 × 10−1 2.070467 × 10−2 2.057702 × 10−2 2.77837 × 10−30 6.927052 × 10−1 Destination_IP 2.773583 × 10−7 1.824271 × 10−2 7.112974 × 10−3 4.124236 × 10−1 2.091758 × 10−4 5.842059 × 10−2 1.562471 × 10−1 2.848223 × 10−1 Destination_Port 1.232595 × 10−30 1.232595 × 10−3 5.772448 × 10−3 1.774937 × 10−28 8.493351 × 10−30 2.097338 × 10−29 1.203706 × 10−29 4.930381 × 10−30 Flow.Duration 1.309048 4.731603 2.933845 × 10−4 3.366436 × 10−1 4.514761 5.269066 9.913239 6.871774 × 10−1 Total.Fwd.Packets 8.387569 × 10−2 2.23493 × 10−3 2.357599 × 10−2 3.299392 × 10−3 3.453238 × 10−2 1.038723 × 10−1 6.913426 × 10−1 4.477584

For the HTTP traffic 8 principal components which correspond to 98.09618% of the explained variance are selected from Table 1. Those selected 8 PCs and the first 6 (head) out of the total number of features are shown in Table 2. Each PC is constructed from a linear combination of the total features and their multiplying coefficients specified the table. Mach. Learn. Knowl. Extr. 2019, 1 278 2. SSH Traffic PCA Analysis

2. SSHThe Trafficresults PCAof SSH Analysis traffic PCA analysis are demonstrated below. Figure 5 shows the scree plot of the dimensions with respect to percentage of explained variance and eigenvalues. The elbow The results of SSH traffic PCA analysis are demonstrated below. Figure5 shows the scree plot of method can be used to determine the number of dimensions to retain. Equivalently, the cumulative the dimensions with respect to percentage of explained variance and eigenvalues. The elbow method percent of variance with respect to the number of dimensions, as shown in Table 3, can be used to can be used to determine the number of dimensions to retain. Equivalently, the cumulative percent of determine the number of dimensions to be retained. variance with respect to the number of dimensions, as shown in Table3, can be used to determine the number of dimensions to be retained.

(a) (b)

Figure 5. (a) Scree PlotPlot of the percentagepercentage ofof explainedexplained variance;variance; ((bb)) ScreeScree plotplot ofof eigenvalues.eigenvalues.

Table 3.3. PrincipalPrincipal componentscomponents withwith theirtheir variancevariance contribution.contribution.

EigenvaluePercent Percent of of VarianceCumulative Cumulative Percent Percent of of Variance Eigenvalue Dim.1 1.11834 × 1014 Variance8.53962 × 101 Variance85.39622 13 1 Dim.2Dim.1 1.11834 1.77023 × 101014 8.539621.35175 × 101 × 10 85.3962298.91367 Dim.3 6.84686 × 1011 5.22826 × 10−1 99.4365 Dim.2 1.77023 × 1013 1.35175 × 101 98.91367 Dim.4 4.27484 × 1011 3.26427 × 10−1 99.76292 11 −1 Dim.5Dim.3 6.84686 2.53906 × 101011 5.228261.93883 × 10 × 10−1 99.4365 99.95681 Dim.6Dim.4 4.27484 2.83901 × 10101110 3.264272.16787 × 10−×1 10−2 99.7629299.97848 Dim.7Dim.5 2.53906 1.66896 × 10101110 1.938831.27442 × 10−×1 10−2 99.9568199.99123 9 −3 Dim.8Dim.6 2.83901 6.49554 ×× 101010 2.167874.95999 × 10−×2 10 99.9784899.99619 × 9 × −3 Dim.9Dim.7 1.66896 3.08202 × 101010 1.274422.35343 × 10−2 10 99.9912399.99854 Dim.10 1.31229 × 109 1.00207 × 10−3 99.99954 Dim.8 6.49554 × 109 4.95999 × 10−3 99.99619 Dim.11 3.37909 × 108 2.58027 × 10−4 99.9998 9 −3 Dim.12Dim.9 3.08202 1.19652 × 10108 2.353439.13658 × 10 × 10−5 99.9985499.99989 Dim.13Dim.10 1.31229 5.03480 × 101097 1.002073.84457 × 10−×3 10−5 99.9995499.99993 − Dim.14Dim.11 3.37909 3.36857 × 101087 2.580272.57224 × 10−×4 10 5 99.9998 99.99996 7 −5 Dim.15Dim.12 1.19652 2.31915 × 10108 9.136581.77090 × 10−×5 10 99.9998999.99998 Dim.16 1.72495 × 107 1.31717 × 10−5 99.99999 Dim.13 5.03480 × 107 3.84457 × 10−5 99.99993 Dim.17 1.00092 × 107 7.64299 × 10−6 100 Dim.14 3.36857 × 107 2.57224 × 10−5 99.99996 Dim.15 2.31915 × 107 1.77090 × 10−5 99.99998 For theDim.16 SSH traffic, 1.72495 4 principal × 107 components1.31717 × 10 which−5 correspond to99.99999 99.76292% of the explained variance areDim.17 selected from1.00092 Table × 103.7 The first7.64299 three × dimensions 10−6 of the PCA100 retains slightly over 99% of the total variance (i.e., information) contained in the data. Those selected 3 PCs and the first 6 (head) out of the total number of features are shown in Table4.

Mach. Learn. Knowl. Extr. 2018, 2, x; doi: FOR PEER REVIEW www.mdpi.com/journal/make Mach. Learn. Knowl. Extr. 2018, 2, x FOR PEER REVIEW 2 of 22

Mach. Learn. Knowl. Extr. 2018, 2, x FOR PEER REVIEW 2 of 22 For the SSH traffic, 4 principal components which correspond to 99.76292% of the explained varianceFor the SSH are selectedtraffic, 4 from principal Table components3. The first three which dimensions correspond of theto 99.76292%PCA retains of slightly the explained over 99 % of the total variance (i.e., information) contained in the data. Those selected 3 PCs and the first 6 (head) varianceMach. Learn. are selected Knowl. Extr. from2019 ,Table1 3. The first three dimensions of the PCA retains slightly over 99% of279 the totalout ofvariance the total (i.e. number, information) of features contained are shown in the in data. Table Those 4. selected 3 PCs and the first 6 (head) out of the total number of features are shown in Table 4. TableTable 4. The4. The selected selected 4 Principal4 Principal components components and and head head (6 of(6 theof the original original features features only only displayed). displayed).

Table 4. The selected 4 PrincipalPC1 componentsPC1 and PC2headPC2 (6 of the original PC3 PC3features only displayed)PC4 PC4 . −10 −9 −8 −8 Flow_ID Flow_ID5.20233 ×5.20233PC110−10 × 109.18848 PC29.18848× 10− 9× 10 4.46286PC34.46286 × ×10 10−8 PC49.021679.02167 × ×1010 −8 −13 −13 −12 −12 −11−11 −11−11 Source_IPSource_IP6.00175 ×6.0017510 − 10× 101.93802 1.93802× 10 −×9 10 1.488501.48850× −×108 10 1.776741.77674 −×8 ×1010 Flow_ID 5.20233 −× 10 9.18848 × 10 4.46286 × 10 − 9.02167 × 10 − Destination_IP × 30 −30 × 30−30 × −29 29 Destination_IP1.23260 1.2326010 − 13× 10 0.000000.00000−12 1.232601.23260− 11×10 10 1.018821.01882− 11× 1010 Source_IP 6.00175 × 10 1.93802 × 10 1.48850 × 10 1.77674 × 10 −30 Destination_Port 0.00000 0.00000 0.00000 1.23260 × 10−30 Destination_Port 0.00000−30 0.00000 0.00000−30 1.23260− 29× 10 Flow.DurationDestination_IP 3.526241.23260× 10 ×1 10 7.109290.00000× 10 −1 1.232608.77584 × 10× 10 −1.018821 7.02152× 10 × 10−2 Flow.Duration 3.52624 × 101 7.10929 × 10−1 8.77584 × 10−1 7.02152 × 10−2 Total.Fwd.PacketsDestination_Port1.22041 ×0.0000010−11 5.029310.00000× 10 −11 0.000006.34210 × 10−1.232609 4.41869 × 10−30 × 10−10 −11 −11 −9 −10 Flow.DurationTotal.Fwd.Packets 3.52624 1.22041 × 10 1× 107.10929 5.02931 × 10 −×1 108.77584 6.34210 × 10− 1× 107.02152 4.41869 × 10 −×2 10 Total.Fwd.Packets 1.22041 × 10−11 5.02931 × 10−11 6.34210 × 10−9 4.41869 × 10−10 VectorVector Quantization Quantization Vector QuantizationTheThe goal goal of the of vector the vector quantization quantization is to simplify is to the simplify dataset the from dataset a complex from higher a complex dimensional higher space into a lower dimensional space so that it can be easier for visualization and find patterns. In this dimensionalThe goal of space the vectorinto a lower quantization dimensional is to space simplify so that the it can dataset be easier from for a visualization complex higher and find work, it is achieved by using a very common unsupervised machine learning algorithm such as dimensionalpatterns. space In this into work, a lower it isdimensional achieved byspace using so that a very it can common be easier unsupervised for visualization machine and find learning K-Means clustering. patterns.algorithm In this such work, as K it-Means is achieved clustering. by using a very common unsupervised machine learning To determine the number of clusters (K) in K-Means, the simplest method involves plotting the algorithmTo such determine as K-Means the number clustering. of clusters (K) in K-Means, the simplest method involves plotting the number of clusters against the within groups sum of squares and find pick the ‘elbow’ point in this numberTo determine of clusters the number against of the clusters within (K) groups in K- Means,sum of thesquares simplest and methodfind pick involves the ‘elbow’ plotting point the in this plot. This is similar in concept with the scree plot for the PCA discussed in Section 2.3. numberplot. of This clusters is similar against in conceptthe within with groups the scree sum plot of squares for the PCAand finddiscussed pick the in S‘elbow’ection 2.3 point. in this plot.1. 1.ThisHTTP HTTPis similarClustering Clustering in concept Analysis Analysis with the scree plot for the PCA discussed in Section 2.3. 1. HTTPK-MeansK -ClusteringMeans clustering clustering Analysis is is applied applied on on the the HTTP HTTP traffic traffic after after PCA PCA and and the the number number of of clusters cluster iss is determined where the elbow occurs in Figure6 which is K = 4. The plot shows the within cluster sum determinedK-Means clustering where the is elbow applied occurs on the in Figure HTTP 6 traffic which after is K=4. PCA The and plot the shows number the within of cluster clusters is sum of squares (wcss) as the number of clusters (K) varies. determinedof squares where (wcss) the aselbow the number occurs in of Figure clusters 6 which(K) varies. is K=4. The plot shows the within cluster sum of squares (wcss) as the number of clusters (K) varies.

Figure 6. The wcss vs. number of clusters for HTTP traffic. Figure 6. The wcss vs number of clusters for HTTP traffic. 2. SSH Clustering AnalysisFigure 6. The wcss vs number of clusters for HTTP traffic. 2. SSH Clustering Analysis On the SSH traffic, K-Means is applied after PCA analysis similar to the HTTP traffic above and 2. SSH Clustering Analysis the number of clusters where the elbow occurs, K = 3, is selected from Figure7.

Figure 7. The wcss vs number of clusters for SSH traffic. Figure 7. The wcss vs. number of clusters for SSH traffic. Figure 7. The wcss vs number of clusters for SSH traffic.

Mach. Learn. Knowl. Extr. 2018, 2, x FOR PEER REVIEW 3 of 22

On the SSH traffic, K-Means is applied after PCA analysis similar to the HTTP traffic above and Mach.the number Learn. Knowl. of clusters Extr. 2019 where, 1 the elbow occurs, K = 3, is selected from Figure 7. 280

3.2. Layered HMM Experimental Results 3.2. Layered HMM Experimental Results For the simulation of the LHMM, the two HMMs considered the lower layer are HTTP and SSH For the simulation of the LHMM, the two HMMs considered the lower layer are HTTP and traffic. SSH traffic. 3.2.1. Training the LHMM 3.2.1. Training the LHMM The lower layer HMMs are trained using their corresponding training data and the optimized The lower layer HMMs are trained using their corresponding training data and the optimized model parameters are determined using the Baum-Welch algorithm. model parameters are determined using the Baum-Welch algorithm.

1.1. HTTPHTTP HMM HMM training training HMM model parameters (A, B, Π) after training are as shown below. HMM model parameters (A, B, Π) after training are as shown below. 0.9827 0.0173 =" # 00.9827.0140 0.01730.9860 A = 0.3088 0.0973 0.2007 0.3932 = 0.0140 0.9860 " 0.0000 0.8129 0.0952 0.0919 # 0.3088 0.0973 0.2007 0.3932 B = 1 0.0000 0.8129 = 0.0952 0.0919 " 0 # 1 π = The number of hidden states in the HTTP training0 traffic is shown in Table 5. The corresponding state symbols sequence is plotted against the HTTP training data in Figure The number of hidden states in the HTTP training traffic is shown in Table5. The corresponding state8. symbols sequence is plotted against the HTTP training data in Figure8.

Table 5.5. HiddenHidden StateState SymbolsSymbols ofof thethe HTTPHTTP traffic.traffic.

StateState Symbols Symbols HTTP HTTP 11 HTTP HTTP-BENIGN-BENIGN 22 HTTP HTTP-Web-attack-bruteforce-Web-attack-bruteforce

FigureFigure 8.8. StateState symbolssymbols againstagainst thethe timetime seriesseries HTTPHTTP trainingtraining data.data.

2.2. TrainingTraining the the SSH SSH HMM HMM HMMHMM model model parameters parameters (A, B,(A, Π) B, afterΠ) after training training were were found found to be to be 0.9772 0.0228 =" # 00.9772.0308 0.02280.9692 A 0=.6135 0.1518 0.2348 = 0.0308 0.9692 " 0.5092 0.2482 0.2427# 0.6135 0.1518 0.2348 B = 1 0.5092 = 0.2482 0.2427 0" # 1 π = 0 Mach. Learn. Knowl. Extr. 2019, 1 281 Mach. Learn. Knowl. Extr. 2018, 2, x FOR PEER REVIEW 4 of 22

The numberThe of number hidden states of hidden in the statesSSH trai inning the traffic SSH training is shown trafficin Table is 6 shown. The corresponding in Table6. The state corresponding symbolsstate sequ symbolsence is sequence plotted against is plotted the SSH against training the data SSH in training Figure 9 data. in Figure9.

TableTable 6. Hidden 6. Hidden State State Symbols Symbols of the of SSH the SSH traffic. traffic.

StateState Symbols Symbols SSH SSH 1 1SSH- SSH-BENIGNBENIGN 2 2SSH- SSH-PatatorPatator

FigureFigure 9. State 9. State symbols symbols against against the time the series SSH SSHtraining training data data..

3. 3.Training Training Upper Upper Layer Layer HMM HMM FollowingFollowing the thetraining training the thelower lower layer layer HMMs, HMMs, the themodel model parameters parameters (A, (A,B, Π) B, afterΠ) after training training of of the theupper upper layer layer HMM HMM were were found found to be to be   0.98600.9860 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0. 0.01400140 ⎡0.0011 0.8962 0.0026 0.0988 0.0014⎤ ⎢  0.0011 0.8962 0.0026 0.0988 0.0014⎥  = 0.0000 0.2557 0.2870 0.4240 0.0334  ⎢  ⎥  A⎢0=.0255 0.0000 0.7642 0.25570.0024 0.2870 0.1401 0.4240 0. 0.03340678⎥    ⎣0.0568 0.0255 0.0105 0.7642 0.0684 0.0024 0.0007 0.1401 0. 0.06788636⎦  0.0000 1.0000 0.0000 0.0000 ⎡ 0.0568 0.0105 0.0684 0.0007 0.8636⎤ 1.0000 0.0000 0.0000 0.0000  ⎢ 0.0000 1.0000 0.0000 0.0000⎥ = ⎢ 0.9996 0.0000 0.0004 0.0000 ⎥  1.0000 0.0000 0.0000 0.0000  ⎢ 1.0000 0.0000 0.0000 0.0000 ⎥  ⎣  ⎦  B0=.0000 0.9996 0.0000 0.0000 1.0000 0.00040. 0.00000000     1.0000 0.0000 0.0000 0.0000  0.0000 0.0000⎡ 1 ⎤ 1.0000 0.0000 ⎢ 0 ⎥  = ⎢ 0 ⎥ ⎢ 0 ⎥1    ⎣ 0 ⎦   0  π =    0  The hidden states in the upper layer HMM training traffic is shown in Table 7. The corresponding  0  state symbols sequence is plotted against the upper layer HMM training data in Figure 10. 0

The hiddenTable states 7. inHidden the upper State Symbols layer HMM of the training Upper layer traffic in isthe shown training in Tabledata. 7. The corresponding state symbols sequenceState Symbols is plotted against theHTTP upper layer HMM trainingSSH data in Figure 10. 1 HTTP-BENIGN SSH-BENIGN 2 HTTP-Web-attack-bruteforce SSH-Patator 3 HTTP-Web-attack-bruteforce SSH-BENIGN 4 HTTP-Web-attack-bruteforce SSH-Patator 5 HTTP-BENIGN SSH-Patator

Mach. Learn. Knowl. Extr. 2019, 1 282

Table 7. Hidden State Symbols of the Upper layer in the training data.

State Symbols HTTP SSH 1 HTTP-BENIGN SSH-BENIGN 2 HTTP-Web-attack-bruteforce SSH-Patator 3 HTTP-Web-attack-bruteforce SSH-BENIGN 4 HTTP-Web-attack-bruteforce SSH-Patator Mach. Learn. Knowl. Extr. 2018,5 2, x FOR PEER REVIEW HTTP-BENIGN SSH-Patator 5 of 22 Mach. Learn. Knowl. Extr. 2018, 2, x FOR PEER REVIEW 5 of 22

FigureFigure 10.10. StateState symbolssymbols againstagainst thethe timetime seriesseries UpperUpper trainingtraining data.data. Figure 10. State symbols against the time series Upper training data. 3.2.2. Testing the LHMM 3.2.2. Testing the LHMM 3.2.2. Testing the LHMM The sequence of network states during testing are determined using the Viterbi algorithm which The sequence of network states during testing are determined using the Viterbi algorithm uses asThe an sequence input the modelof network parameters states that during are determined testing are duringdetermined training using phase. the Viterbi algorithm which uses as an input the model parameters that are determined during training phase. which uses as an input the model parameters that are determined during training phase. 1. Testing HTTP HMM 1. Testing HTTP HMM 1. Testing HTTP HMM During testing, the hidden states of the HTTP HMM shown in Table8 are similar to the training During testing, the hidden states of the HTTP HMM shown in Table 8 are similar to the training phaseDuring hidden testing states., Thethe hidden corresponding states of sate the symbolHTTP HMM sequences shown are in plotted Table with8 are thesimilar HTTP to testingthe training data phase hidden states. The corresponding sate symbol sequences are plotted with the HTTP testing inphase Figure hidden 11. states. The corresponding sate symbol sequences are plotted with the HTTP testing data in Figure 11. data in Figure 11. Table 8. Hidden State Symbols of the HTTP traffic during testing. Table 8. Hidden State Symbols of the HTTP traffic during testing. Table 8. Hidden State Symbols of the HTTP traffic during testing. State Symbols HTTP State Symbols HTTP State Symbols HTTP 11 HTTP HTTP-BENIGN-BENIGN 12 HTTP-Web-attack-bruteforceHTTP-BENIGN 2 HTTP-Web-attack-bruteforce 2 HTTP-Web-attack-bruteforce

Figure 11. State symbols against the time series HTTP test data FigureFigure 11. 11.State State symbolssymbols againstagainst thethe timetime series series HTTP HTTP test test data. data 2. Testing SSH HMM 2. Testing SSH HMM Similarly, the SSH HMM hidden state symbols are the same as the SSH training data hidden Similarly, the SSH HMM hidden state symbols are the same as the SSH training data hidden states as shown in Table 9. These state symbols are plotted against a time series data of the testing states as shown in Table 9. These state symbols are plotted against a time series data of the testing data as shown in Figure 12. data as shown in Figure 12. Table 9. Hidden State Symbols of the SSH traffic in testing data. Table 9. Hidden State Symbols of the SSH traffic in testing data. State Symbols SSH State Symbols SSH 1 SSH-BENIGN 1 SSH-BENIGN 2 SSH-Patator 2 SSH-Patator

Mach. Learn. Knowl. Extr. 2019, 1 283

2. Testing SSH HMM Similarly, the SSH HMM hidden state symbols are the same as the SSH training data hidden states as shown in Table9. These state symbols are plotted against a time series data of the testing data as shown in Figure 12.

Table 9. Hidden State Symbols of the SSH traffic in testing data.

State Symbols SSH Mach. Learn. Knowl. Extr. 2018, 2, x FOR PEER REVIEW1 SSH-BENIGN 6 of 22 2 SSH-Patator Mach. Learn. Knowl. Extr. 2018, 2, x FOR PEER REVIEW 6 of 22

Figure 12. State symbols against the time series SSH test data. FigureFigure 12.12. StateState symbolssymbols againstagainst thethe timetime seriesseries SSHSSH testtest data.data. 3. Testing Upper Layer HMM 3.3. TestingTesting Upper Upper Layer Layer HMM HMM The Upper layer HMM testing hidden states are shown in Table 10 and constitute the hidden The Upper layer HMM testing hidden states are shown in Table 10 and constitute the hidden states statesThe of Upper the lower layer layer HMM HMMs testing. And hidden final states results are shown shown in in FigureTable 10 13 and prove constitute the validity the hidden of the ofmu thelti- lowerlayer HMM layer HMMs. in determining And final the results hidden shown states inwithin Figure the 13 IDS prove detection the validity engine of. the multi-layer HMMstates in of determining the lower layer the hidden HMMs states. And within final results the IDS shown detection in Figure engine. 13 prove the validity of the multi-layer HMM in determining the hidden states within the IDS detection engine. Table 10. Hidden State Symbols of the Upper layer testing data. Table 10. Hidden State Symbols of the Upper layer testing data. StateTable Symbols 10. Hidden State SymbolsHTTP of the Upper layer testingSSH data . State Symbols HTTP SSH State Symbols1 HTTPHTTP-BENIGN SSH-SSHBENIGN 12 HTTP- HTTP-BENIGNWeb-attack-bruteforce SSH-BENIGNSSH-Patator 21 HTTP-Web-attack-bruteforceHTTP-BENIGN SSH SSH-Patator-BENIGN 3 HTTP-Web-attack-bruteforce SSH-BENIGN 32 HTTP HTTP-Web-attack-bruteforce-Web-attack-bruteforce SSH SSH-BENIGN-Patator 434 HTTP HTTP-Web-attack-bruteforce-Web-attack-bruteforce SSHSSH SSH-Patator-BENIGN-Patator 545 HTTP- HTTP-BENIGNWebHTTP-attack-BENIGN-bruteforce SSH SSH-Patator-Patator 5 HTTP-BENIGN SSH-Patator

FigureFigure 13.13. StateState symbolssymbols againstagainst thethe timetime seriesseries UpperUpper testtest data. data. Figure 13. State symbols against the time series Upper test data. 4. Discussion. 4. DiscussionA high detection. rate is essential in a machine learning based IDS alongside the evaluation metricsA highaforementioned. detection rate The is main essential aspects in ato machineconsider learningwhen measuring based IDS the alongside accuracy are the evaluation metrics• True aforementioned. Positive (TP): Number The main of aspects intrusions to consider correctly when detected. measuring the accuracy are

• True PositiveNegative (TP): (TN): Number Number of of intrusions non-intrusions correctly correctly detected. detected.

• TrueFalse NegativePositive (FP): (TN): Number Number of of non non-intrusions-intrusions incorrectly correctly detected. detected.

• False PositiveNegative (FP): (FN): Number Number of of non intrusions-intrusions incorrectly incorrectly detected. detected. • False Negative (FN): Number of intrusions incorrectly detected.

Mach. Learn. Knowl. Extr. 2019, 1 284

4. Discussion A high detection rate is essential in a machine learning based IDS alongside the evaluation metrics aforementioned. The main aspects to consider when measuring the accuracy are

• True Positive (TP): Number of intrusions correctly detected. • True Negative (TN): Number of non-intrusions correctly detected. • False Positive (FP): Number of non-intrusions incorrectly detected. • False Negative (FN): Number of intrusions incorrectly detected.

The performance of the LHMM by can be evaluated by calculating the common performance measures: Accuracy, Sensitivity, Specificity, Precision, Recall and F-Measure. Those metrics are among the few considered which are commonly used for evaluating IDS performance [30–32]. a) Accuracy: the proportion of true results (both true negatives and true positives) with respect to the total number. tp + tn Accuracy = tp + tn + fp + fn b) Precision: the fraction of the states which were classified as the interesting state (loaded in this case) that are really that state. tp Precision = tp + fp c) Recall: the fraction of the interesting states that were correctly predicted as such. It is also referred as Sensitivity. tp Recall = tp + fn d) F-measure: a combination of precision and recall and provides the percentage of positively classified incidents that are truly positive.

2xPrecision × Recall F1 = Precision + Recall

The performance of the LHMM for the above test is as follows:

[Accuracy Precision Recall f_measure] = [0.9898 0.9793 1.0000 0.9895]

Additionally, the CPU consumption, the throughput and the power consumption are important metrics for the evaluation of intrusion detection systems running on different hardware on specific settings such as high-speed networks, or on hardware with limited resources. But in this work the performance of the developed IDS is measured solely on the above metrics. As compared to a single-layer HMM, the layered approach has several advantages: (1) A single- layer HMM possibly have to be trained on a large number of observations space. In this case, the model can be over-fitted when enough training data is not used. As the observation space increases, the amount of data needed to train the model well also increases. As a result it incurs what is commonly referred as the curse of dimensionality. On the contrary, the layers in this approach are trained over small-dimensional observation spaces which results in more stable models and do not require large amount of training data. (2) The lower layer HMMs are defined and trained with their corresponding data as needed. (3) The second layer-HMM is less sensitive to variations in the lower layer features as the observations are the outputs from each lower layer HMMs, which are expected to be well trained. (4) The two layers (lower and upper) are expected to be well trained independently. Thus, we can explore different HMM combination systems. In particular, we can replace the first layers Mach. Learn. Knowl. Extr. 2019, 1 285

HMMs with models that are more suitable for network traffic data sequences, with the goal of gaining understanding of the nature of the data being used. The framework is thus easier to improve and interpret individually at each level. (5) The layered framework in general can be expanded to learn new network traffics that can be defined in the future by adding additional HMMs in the lower layers. The results demonstrate how a Markov Model can capture the statistical behavior of a network and determine the presence of attacks and anomalies based on known normal network behaviors gathered from training data. Using the vector quantization method, we are able to include multiple dimensions of information into the model and this will be helpful in reducing false positives and determining more attack states in the future. The model can be re-trained to identify new network states based on the robustness of the training data. This is a promising approach because it is extensible.

5. Conclusions This work highlights the potential for use of multi-layer HMM-based IDS. PCA using SVD is used for dimension reduction of CICIDS2017 data after feature selection and feature creation. By applying K-Means clustering as a vector quantization technique on the reduced data, the cluster labels are used as a sequence of observation to an HMM model. The IDS is based on multi-layer HMM. The proposed approach has been developed and verified to resolve the common flaws in the application of HMM to IDS commonly referred as the curse of dimensionality. It factors a huge problem of immense dimensionality to a discrete set of manageable and reliable elements. The multi-layer approach can be expanded beyond 2 layers to capture multi-phase attacks over longer spans of time. A pyramid of HMMs can resolve disparate digital events and signatures across protocols and platforms to actionable information where lower layers identify discrete events (such as network scan) and higher layers new states which are the result of multi-phase events of the lower layers. The concepts of this approach have been developed but the full potential has not been demonstrated.

Author Contributions: The authors contributed equally to this work. Funding: This research received no external funding. Conflicts of Interest: The authors declare no conflict of interest.

References

1. Bace, R.; Mell, P. Intrusion Detection Systems. In NIST Special Publication 800-31; November 2001. Available online: https://csrc.nist.gov/publications/detail/sp/800-31/archive/2001-11-01 (accessed on 7 July 2018). 2. Brown, D.J.; Bill Suckow, B.; Wang, T. A Survey of Intrusion Detection Systems; Department of Computer Science, University of California: San Diego, CA, USA; Available online: http://citeseerx.ist.psu.edu/ viewdoc/download?doi=10.1.1.87.408&rep=rep1&type=pdf (accessed on 10 September 2018). 3. Cisco 2018 Annual Cybersecurity Report. Available online: https://www.cisco.com/c/en/us/products/ security/security-reports.html (accessed on 14 July 2018). 4. Johns Hopkins University. HMM Profiles for Network Traffic Classification (Extended Abstract). In Towards Better Protocol Identification Using Profile HMMs; JHU Technical Report, JHU-SPAR051201; Johns Hopkins University: Baltimore, MD, USA, 2004. 5. Zegeye, W.K.; Moazzami, F.; Richard Dean, R.A. Design of Intrusion Detection System (IDS) Using Hidden Markov Model (HMM). In Proceedings of the International Telemetering Conference, Glendale, AZ, USA, 5–8 November 2018. 6. Ourston, D.; Matzner, S.; Stump, W.; Hopkins, B. Applications of Hidden Markov Models to Detecting Multi-stage Network Attacks. In Proceedings of the 36th Hawaii International Conference on System Sciences, Big Island, HI, USA, 6–9 January 2003; p. 10. 7. Shawly, T.; Elghariani, A.; Kobes, J.; Ghafoor, A. Architectures for Detecting Real-time Multiple Multi-stage Network Attacks Using Hidden Markov Model. Cryptography and Security (cs.CR). arXiv, 2018; arXiv:1807.09764. 8. Rust, J. Using Randomization to Break the Curse of Dimensionality. Econometrica 1997, 65, 487–516. [CrossRef] Mach. Learn. Knowl. Extr. 2019, 1 286

9. Cherki, D. Decomposition des Problemes de Decision Markoviens. Ph.D. Thesis, Faculty of Science Rabat, Rabat, Morocco, 2002; pp. 64–69. 10. Amjad, M.; Tobi, A.; Duncan, I. KDD 1999 generation faults: A review and analysis. J. Cyber Secur. Technol. 2018.[CrossRef] 11. Hindy, H.; Brosset, D.; Bayne, E.; Seeam, A.; Tachtatzis, C.; Atkinson, R.; Bellekens, X. A Taxonomy and Survey of Intrusion Detection System Design Techniques, Network Threats and Datasets. arXiv, 2018; arXiv:1806.03517v1. 12. Sharafaldin, I.; Lashkari, A.A.; Ghorbani, A.A. Toward Generating a New Intrusion Detection Dataset and Intrusion Traffic Characterization. In Proceedings of the 4th International Conference on Information Systems Security and Privacy (ICISSP), INSTICC, Funchal, Portugal, 22–24 January 2018; pp. 108–116. [CrossRef] 13. Sharafaldin, I.; Gharib, A.; Lashkari, A.; Ghorbani, A.A. Towards a reliable intrusion detection benchmark dataset. Softw. Netw. 2017, 177–200. [CrossRef] 14. CIC. CICFlowMeter (2017); Canadian Institute for Cybersecurity (CIC): Fredericton, NB, Canada, 2017. 15. Manhart, K. Artificial Intelligence Modelling: Data Driven and Theory Driven Approaches. In Social Science Micro Simulation (Dagstuhl Seminar, May, 1995); Springer: Berlin/Heidelberg, Germany, 1996; pp. 416–431. 16. Pivovarov, R.; Elhadad, N. A hybrid knowledge-based and data-driven approach to identifying semantically similar concepts. J. Biomed. Inform. 2012, 45, 471–481. [CrossRef][PubMed] 17. Wyse, N.; Dubes, R.; Jain, A.K. A critical evaluation of intrinsic dimensionality algorithms. In in Practice (North-Holland Amsterdam); Gelsema, E.S., Kanal, L.N., Eds.; North-Holland Pub: New York, NY, USA, 1980; pp. 415–425. 18. Smith, L. A tutorial on Principal Components Analysis. In Technical Report OUCS-2002-12; Department of Computer Science, University of Otago: Dunedin, New Zealand; Available online: http://www.cs.otago.ac. nz/research/publications/OUCS-2002-12.pdf (accessed on 11 June 2018). 19. Shlens, J. A Tutorial on Principal Component Analysis; Version 3.02; Google Research: Mountain View, CA, USA, 2014. 20. Cattell, R.B. The scree test for the number of factors. Multivar. Behav. Res. 1966, 1, 245–276. [CrossRef] [PubMed] 21. Kaiser, H.F. The application of electronic computers to factor analysis. Educ. Psychol. Meas. 1960, 20, 141–151. [CrossRef] 22. McCune, B.; Grace, J.B.; Urban, D.L. Analysis of Ecological Communities; MjM Software Design: Gleneden Beach, OR, USA, 2002. 23. Stuart, P.L. Least squares quantization in pcm. IEEE Trans. Inf. Theory 1982, 28, 129–137. 24. Alpaydin, E. Introduction to Machine Learning; MIT Press: Cambridge, MA, USA, 2004. 25. Ng, A. The K-Means Clustering Algorithm. CS229: Machine Learning. Available online: http://cs229.stanford. edu/notes/cs229-notes7a.pdf (accessed on 14 September 2018). 26. Rabiner, L.R.; Juang, B. An Introduction to hidden Markov Models. IEEE ASSP Mag. 1986, 3, 4–16. [CrossRef] 27. Rabiner, L.R. A tutorial on hidden Markov Models and selected applications in . Proc. IEEE 1989, 77, 257–286. [CrossRef] 28. Baum, L.; Petrie, T. Statistical inference for probabilistic functions of finite state Markov Chains. Ann. Math. Stat. 1966, 37, 1554–1563. [CrossRef] 29. Bilmes, J. A Gentle Tutorial on EM Algorithm and Its Application to Parameter Estimation for Gasussian Mixture and Hidden Markov Models; International Computer Science Institute: Berkeley, CA, USA, 1997. 30. Aminanto, M.E.; Choi, R.; Tanuwidjaja, H.C.; Yoo, P.D.; Kim, K. Deep Abstraction and Weighted Feature Selection for Wi-Fi Impersonation Detection. IEEE Trans. Inf. Forensics Secur. 2018, 13, 621–636. [CrossRef] 31. Atli, B. Anomaly-Based Intrusion Detection by Modeling Probability Distributions of Flow Characteristics. Ph.D. Thesis, Aalto University, Helsinki, Finland, 2017. Available online: http://urn.fi/URN:NBN:fi: aalto-201710307348. (accessed on 14 July 2018). 32. Hodo, E.; Bellekens, X.; Hamilton, A.; Tachtatzis, C.; Atkinson, R. Shallow and deep networks intrusion detection system: A taxonomy and survey. arXiv, 2017; arXiv:1701.02145.

© 2018 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (http://creativecommons.org/licenses/by/4.0/).