An Intelligent Two-Layer Intrusion Detection System For The Internet of Things
An Intelligent Two-Layer Intrusion Detection System For The Internet of Things
Abstract—The Internet of Things (IoT) has become an because it can facilitate people’s interactions with real-world ap-
enabler paradigm for different applications, such as health- plications. The development of IoT systems goes hand-in-hand
care, education, agriculture, smart homes, and recently, with advances in technologies such as sensing, actuating, cloud
enterprise systems. Significant advances in IoT networks
have been hindered by security vulnerabilities and threats, computing, and big data analytics and visualization [1].
which, if not addressed, can negatively impact the deploy- An enterprise Internet of Things (E-IoT) is an anticipated
ment and operation of IoT-enabled systems. This article extension of the IoT model. An E-IoT comprises the same IoT
addresses IoT security and presents an intelligent two- components and facilitates the engagement of IoT devices (e.g.,
layer intrusion detection system for IoT. The system’s in- sensors and actuators) to automate enterprise operations, such as
telligence is driven by machine learning techniques for in-
trusion detection, with the two-layer architecture handling business processes. An E-IoT can enhance decision-making and
flow-based and packet-based features. By selecting sig- improve an enterprise’s efficiency by collecting, aggregating,
nificant features, the time overhead is minimized without analyzing, and visualizing heterogeneous data from different
affecting detection accuracy. The uniqueness and novelty sensors [2].
of the proposed system emerge from combining machine The development of the IoT has turned it into a mandatory
learning and selection modules for flow-based and packet-
based features. The proposed intrusion detection works at enabler for many applications. However, the different compo-
the network layer, and hence, it is device and application nents and layers of an IoT network are vulnerable to various
transparent. In our experiments, the proposed system had security threats [3] that could affect whatever application the
an accuracy of 99.15% for packet-based features with a IoT is used for [4], [5]. Therefore, security is a key concern
testing time of 0.357 µs. The flow-based classifier had an for any real-world smart environment based on the IoT model.
accuracy of 99.66% with a testing time of 0.410 µs. A com-
parison demonstrated that the proposed system outper- Different approaches have been adopted to address these security
formed other methods described in the literature. Thus, it threats [6]–[9].
is an accurate and lightweight tool for detecting intrusions Limitations in the computing capabilities and storage of IoT
in IoT systems. devices have made it difficult to deploy standard encryption tech-
Index Terms—Efficiency, flow-based features, Internet of niques and common intrusion detection systems (IDSs). There-
Things (IoT), intrusion detection, machine learning, packet- fore, customized intrusion detection as a second line of defense
based features. has become imperative for IoT systems. Intrusion detection
classifies traffic and applications as benign or malicious [10].
I. INTRODUCTION
Therefore, a machine learning classifier is the right tool for
HE Internet of Things (IoT) has evolved to become an
T enabler for various applications, including healthcare, au-
tonomous driving, education, agriculture, military, smart homes,
building an accurate IDS [11], [12]. According to the survey
described in [4], a few IDSs have been specifically designed and
customized for the IoT.
and recently, enterprise systems. An IoT network is beneficial This study addresses the lack of an efficient IDS that is fully
customized for the IoT and presents an intelligent two-layer IDS
Manuscript received 10 April 2022; revised 15 June 2022; accepted based on machine learning. The central idea of the proposed
30 June 2022. Date of publication 18 July 2022; date of current version system is that it combines flow-based and packet-based features
8 November 2022. Paper no. TII-22-1533. (Corresponding author: Ali
Ismail Awad.)
to achieve high detection accuracy. Furthermore, only the most
Mohammed M. Alani is with the School of IT Administration and influential features are used, which hence, reduces the detection
Security,Seneca College of Applied Arts and Technology, Toronto, M2J time and the processing load for the detection process.
2X5, Canada, and also with Toronto Metropolitan University, Toronto,
ON M5B 2H3, Canada (e-mail: [email protected]).
As discussed in Section II, previous research on intrusion de-
Ali Ismail Awad is with the College of Information Technology, United tection in IoT environments has focused on either flow-based or
Arab Emirates University, Al Ain 17551, UAE, with the Department of packet-based features. Limiting the detection process to packet-
Computer Science, Electrical and Space Engineering, Luleå University
of Technology, 971 87 Luleå, Sweden, also with the Electrical Engi-
or flow-specific features reduces the performance in detecting
neering Department, Faculty of Engineering, Al-Azhar University, Qena various types of attacks. Malicious actors utilize different attack
83513, Egypt, and also with the Centre for Security, Communications techniques. These may rely on individual malicious packets,
and Network Research, University of Plymouth, PL4 8AA Plymouth, U.K.
(e-mail: [email protected]; [email protected]).
such as in port scanning, or on a group of malicious packets that
Color versions of one or more figures in this article are available at can be compiled into a network flow, such as man-in-the-middle
https://doi.org/10.1109/TII.2022.3192035. attacks. In this research, we address this gap by devising a
Digital Object Identifier 10.1109/TII.2022.3192035
1551-3203 © 2022 IEEE. Personal use is permitted, but republication/redistribution requires IEEE permission.
See https://www.ieee.org/publications/rights/index.html for more information.
Authorized licensed use limited to: UNIVERSITY TEKNOLOGI MALAYSIA. Downloaded on February 13,2023 at 02:58:30 UTC from IEEE Xplore. Restrictions apply.
684 IEEE TRANSACTIONS ON INDUSTRIAL INFORMATICS, VOL. 19, NO. 1, JANUARY 2023
two-layer system that detects an attack through both packet and Pajouh et al. [14] presented a two-layer dimension reduction
network flow features. and two-tier classification model for anomaly-based intrusion
detection in IoT backbone networks. Linear discriminant anal-
A. Research Contributions ysis (LDA) and principal component analysis (PCA) were used
for feature reduction. The system uses a naive Bayes classifier
Our research into the proposed IDS makes the following to classify traffic, and then the normal traffic is passed through
contributions. a certainty-factor k-nearest neighbor (CF-KNN) classifier as an
1) This research presents a novel two-layer IoT IDS based on additional check. The accuracy achieved was 84.86% with an
machine learning that handles traffic at both packet level FPR of 4.86% measured using the NSL-KDD dataset. However,
and flow level. To the best of our knowledge, the proposed the detection time was not reported.
two-layer architecture handling two types of features is Li et al. [15] proposed a two-stage IDS based on the Bat
novel and unique. algorithm (BAT) and artificial intelligence for software-defined
2) The proposed IDS relies on a reduced number of fea- IoT networks. It is flow-based and can capture network flows
tures, which helps to make the system more efficient to detect attacks. The system was evaluated with the KDD Cup
and realizable. The feature selection technique used not 1999 dataset and achieved a detection accuracy of 96.42% with
only reduces the dimensionality of the data going into the an FPR of 0.98%. The time overhead proportionally increased
classifier but also reduces the number of features that the with the number of flows, and reached almost 4.5 s for 5 × 104
system needs to collect in the data acquisition phase of flows.
deployment. In [16], the authors proposed an intrusion detection frame-
3) The selected classifiers achieve very high accuracy, low work with a dense random neural network (DnRaNN) for the
false positive rate (FPR), low false negative rate (FNR), IoT. It had a detection accuracy of 99.14% and 99.05% for binary
and reduced detection time in comparison to other ap- class and multi-class classification, respectively. However, the
proaches. time overhead and the complexity of the proposed framework
Compared to other systems described in the literature, the were not measured.
proposed IDS for IoT applications is unique and efficient due Kamaldeep et al. [17] developed an IDS for the IoT cross-
to its use of both packet-based and flow-based features and its layer called IoT-Sentry. The system achieved an accuracy of
two-layer architecture and because it selects the most influential 99.46%, evaluated on a non-standard dataset, compared to its
features. Furthermore, the proposed system works mainly at the competitors. IoT-Sentry uses only packet-based features and
network layer. Hence, it is application transparent and conse- guards against only a limited number of attacks. No details were
quently, can be used as a valuable security measure for E-IoT given of the time overhead.
applications. Recently, in 2022, Saba et al. [18] proposed the deployment
of deep learning via a convolutional neural network (CNN)
B. Paper Layout for anomaly-based detection. This IDS can efficiently examine
The rest of this article is organized as follows. The introduc- all the traffic flowing across an IoT system. The model was
tion is presented in Section I. Section II presents previous works evaluated using the NID and BoT-IoT [19] datasets, attaining
relevant to this study. The information introduced in that sec- accuracies of 99.51% and 92.85%, respectively. The study did
tion is later utilized in the comparative analysis of the proposed not consider feature optimization, and the detection time was
system and other systems. The architecture and components of not reported.
the proposed IDS are described in Section III. The dataset used, As demonstrated by this literature review, intrusion detection
including the flow-based and packet-based features, is discussed is an outstanding problem that is highly relevant to the current
in Section IV. The experiments and the results are presented IoT and cybersecurity research communities. Based on a careful
in Section V. Section VI is a discussion of the results and the analysis of the relevant literature, we concluded that realizing
research limitations. Finally, Section VII concludes this article, a balance of superior detection accuracy and reduced detection
along with suggestions for future research. time with a simple and implementable machine learning model
was still a valid challenge, and this motivated the current study.
Table IX briefly compares the performance of the IDSs described
II. RELATED WORK in the literature review with the proposed system.
Intrusion detection has been the subject of a considerable
amount of published research. Particular attention has been
III. OVERVIEW OF THE PROPOSED SYSTEM
given to the deployment of different machine learning models to
achieve high detection accuracy. However, intrusion detection The aim of the proposed system is to provide additional
for the IoT is still a challenge due to the data heterogeneity, protection by utilizing two different machine learning classifiers:
limited device capabilities, and the huge number of possible 1) one classifier operates with packet-extracted features; 2) the
applications. Therefore, an IDS for the IoT has to be a complete other operates with flow-extracted features. Fig. 1 is an overview
system [13]. Artificial intelligence, such as machine learning, of the proposed system.
has been used as a powerful tool to solve IoT security issues due As shown in Fig. 1, the system operation is divided into two
to its ability to cope with data heterogeneity and velocity. phases: 1) development; 2) deployment. During the development
Authorized licensed use limited to: UNIVERSITY TEKNOLOGI MALAYSIA. Downloaded on February 13,2023 at 02:58:30 UTC from IEEE Xplore. Restrictions apply.
ALANI AND AWAD: INTELLIGENT TWO-LAYER INTRUSION DETECTION SYSTEM FOR THE INTERNET OF THINGS 685
Fig. 1. Overview of the proposed IDS for the IoT. The bold blocks have been implemented in this study, while the green blocks are the core
modules of the proposed system.
phase, flow and packet features are separately extracted from the the whole flow is just one packet. In similar attacks where flow
original raw traffic data. Both feature datasets are preprocessed, information is scarce, packet-level detection achieves higher
specifically to address the observations made while individually accuracy for a much faster detection time. These attacks are
examining them (Section IV). Then, a pipeline of classifiers is especially important to prevent because they constitute the first
trained using each dataset independently. Once the best classifier step of higher-risk attacks, such as botnets and remote code
has been identified for each dataset, it is deployed in the next execution.
phase. Another design choice we made was to use classification
In the deployment phase, all incoming and outgoing packets at algorithms that do not use neural networks or deep learning.
a designated interface are captured. The raw traffic is then passed Neural networks are resource-intensive in comparison to other
to two units. The first unit extracts the significant packet-level machine learning classifiers [22]. All blocks with thicker borders
features. These are passed to the packet classifier, which assesses in Fig. 1 have been implemented.
whether each packet is malicious or benign. The other unit
collects each packet as part of a flow. When the flow is complete IV. DATASET
or the flow collection timer has expired, the flow information As the proposed system requires data in both packet-based
is passed to a flow-level feature extraction unit. From the flow and flow-based formats, we selected the dataset “IoT network
features, the flow classifier decides whether a flow is malicious intrusion dataset” presented in [23]. This dataset was created by
or benign. If a malicious packet or flow is detected, the system capturing raw network packets from actual IoT devices, includ-
signals a detection alert. This alert can be used to block the ing actual attack traffic. The dataset consists of 42 packet capture
source of the attack immediately. (pcap) files that include benign and attack packets. The types
Most of the previous works explored in Section II utilize of attack captured in the dataset are denial-of-service (DoS)
flow-based detection, which is commonly described in the lit- SYN-flooding, man-in-the-middle address resolution protocol
erature [20], [21]. The proposed system utilizes both packet- (ARP) spoofing, host scanning, port scanning, and Mirai botnet
and flow-based features to improve the overall accuracy of attacks (host brute force, user datagram protocol (UDP) flood-
detection. Some attacks, specifically reconnaissance attacks, ing, hyper-text transfer protocol (HTTP) flooding, and ACK
such as port scanning and OS detection, do not use a complete flooding).
communication session. For example, port scanning attacks send The dataset has 2 985 994 packets (1 229 718 malicious and
only one packet per port during the scanning process. This 1 756 276 benign). Upon examination, we noticed that 949 284
makes it difficult to identify them based on flow features, as of the packets were for the Mirai UDP flooding attack, so that
Authorized licensed use limited to: UNIVERSITY TEKNOLOGI MALAYSIA. Downloaded on February 13,2023 at 02:58:30 UTC from IEEE Xplore. Restrictions apply.
686 IEEE TRANSACTIONS ON INDUSTRIAL INFORMATICS, VOL. 19, NO. 1, JANUARY 2023
attack type was seriously imbalanced. Hence, we decided to omit perform label encoding on icmp and arp features. If a packet
two of the pcap files that hold Mirai UDP flooding attacks. This is an Internet control messaging protocol (ICMP) packet, the
left a final raw dataset with a total of 2 151 852 packets (419 994 value of the icmp feature is set to 1, otherwise it is set to 0.
malicious and 1 731 858 benign). If the packet is an ARP packet, the value of the arp feature is
To fulfill the goals of this research, two datasets were needed set to 1, otherwise it is set to 0. The second step is to convert
to train the two layers of the proposed system: 1) packet-based the ip.flags and tcp.flags features from hexadecimal to decimal.
dataset; 2) flow-based dataset. The packet-based dataset would For the mutually exclusive features, we set absent values to
include features extracted at the packet level, which are to be −1. We chose −1 over 0 because 0 is a valid value for these
used for training and testing the packet layer. On the other hand, features. Hence, all UDP features will have a value of −1 for
the flow-level dataset would include flow-based features, which each instance of a TCP packet. Similarly, all TCP features will
are to be used in training and testing the flow layer. The following have a value of −1 for instances of UDP packets. The last step
sections discuss the extraction and preprocessing of these two reduces the imbalance between the two classes by randomly
datasets. undersampling benign packets, so that the final dataset contains
66.66% benign and 33.33% malicious instances. It comprises
A. Packet-Based Dataset 1 259 982 instances (839 988 benign and 419 994 malicious),
and all values are populated.
Features for all packets in the 40 pcap files selected were
extracted with the tshark tool [24]. The proposed system used 27
B. Flow-Based Dataset
features based on the description document for the raw dataset.
After extraction, all host-specific features were removed, such as The same 40 pcap files that were used to build the packet-
the source and destination IP and media access control (MAC) based dataset were used for the flow-based dataset. Altogether,
addresses. This was to ensure that the trained model can gener- 20 flow features were extracted for all packets with the Zeek
alize beyond its training dataset. A few empty features were also tool [25], and these were stored in the conn.log file. As for
removed. The resulting dataset comprises 2 151 852 instances, the packets, to ensure that the trained model can generalize
each of which represents 21 features extracted from one packet. beyond its training dataset, all host-specific features were re-
As the research goal is to detect any type of attack, without moved, such as the source and destination IP addresses and flow
distinguishing the specific types, we chose to label the instances timestamps. Two empty features (local_orig and local_resp)
only as “malicious” or “benign.” We did not use the specific were also removed. The resulting dataset comprises 198 064
attack type as a label. instances. Each instance represents 14 features extracted from
Upon examining the resulting dataset, we noted the following one network flow. As with the packets, we labeled the instances
observations. as either “malicious” or “benign.”
1) The features “icmp” and “arp” are in text format. Again, the resulting dataset was examined, and the following
2) The features “ip.flags” and “tcp.flags” are hexadecimal. observations were noted.
3) Some features have mutually exclusive values. Specif- 1) The features “proto,” “service,” “conn_state,” and “his-
ically, all transmission control protocol (TCP)-related tory” are in text format.
features, such as “tcp.flags,” “tcp.checksum.status,” and 2) The number of benign instances was 86 719, while there
“tcp.len,” are missing in instances extracted from UDP were 111 345 malicious instances.
packets, and vice versa. To address the observations listed above, we developed the
4) There is a noticeable imbalance between the malicious preprocessing steps shown in Algorithm 2. The first step of pre-
class and the benign class, with 1 731 858 benign and processing is to remove host-specific features. The second step
419 994 malicious instances. performs label encoding on the proto, service, conn_state, and
To address the observations listed above, we developed the history features. The final step reduces the imbalance between
preprocessing steps shown in Algorithm 1. The first step is to the two classes by randomly oversampling benign packets, so
Authorized licensed use limited to: UNIVERSITY TEKNOLOGI MALAYSIA. Downloaded on February 13,2023 at 02:58:30 UTC from IEEE Xplore. Restrictions apply.
ALANI AND AWAD: INTELLIGENT TWO-LAYER INTRUSION DETECTION SYSTEM FOR THE INTERNET OF THINGS 687
TABLE I
HARDWARE AND SOFTWARE FOR THE IMPLEMENTATION ENVIRONMENT
that the final dataset has 50% benign and 50% malicious in-
stances. It comprises 222 690 instances (111 345 benign and
111 345 malicious) and 14 features. All values are populated.
Authorized licensed use limited to: UNIVERSITY TEKNOLOGI MALAYSIA. Downloaded on February 13,2023 at 02:58:30 UTC from IEEE Xplore. Restrictions apply.
688 IEEE TRANSACTIONS ON INDUSTRIAL INFORMATICS, VOL. 19, NO. 1, JANUARY 2023
TABLE II
INITIAL RESULTS OF PACKET-BASED CLASSIFIER TESTING
Fig. 2. F1 score plotted against the number of features. (a) Number of packet-based features. (b) Number of flow-based features.
Fig. 3. Comparison of accuracy and F1 score for the classifiers with 21- and nine-feature packet-based datasets.
Authorized licensed use limited to: UNIVERSITY TEKNOLOGI MALAYSIA. Downloaded on February 13,2023 at 02:58:30 UTC from IEEE Xplore. Restrictions apply.
ALANI AND AWAD: INTELLIGENT TWO-LAYER INTRUSION DETECTION SYSTEM FOR THE INTERNET OF THINGS 689
TABLE IV
RESULTS OF NINE-FEATURE PACKET-BASED CLASSIFIER TESTING
Fig. 4. Time overhead measured for training and testing processes for 21- and nine-feature packet-based datasets. (a) Training times. (b) Testing
times.
TABLE V
RESULTS OF TEN-FOLD CROSS-VALIDATION OF THE NINE-FEATURE PACKET-BASED DATASET
TABLE VI
INITIAL RESULTS OF FLOW-BASED CLASSIFIER TESTING
TABLE VII
RESULTS OF FIVE-FEATURE FLOW-BASED CLASSIFIER TESTING
the system. Since the F1 score falls with less than five features, dataset. Table VII shows that the performance metrics of XGB,
as shown in Fig. 2(b), to prevent the performance from drop- RF, and DT were not significantly affected, while the perfor-
ping significantly, we decided to use five features, as listed in mance of LR and GNB was noticeably better.
Table III. Fig. 5 compares the performance metrics for the 14- and five-
We then tested the five-feature flow-based dataset to ensure feature datasets. For the XGB and RF classifiers, performance
that its performance was comparable to that of the full-feature did not degrade with fewer features, as the accuracy and F1
Authorized licensed use limited to: UNIVERSITY TEKNOLOGI MALAYSIA. Downloaded on February 13,2023 at 02:58:30 UTC from IEEE Xplore. Restrictions apply.
690 IEEE TRANSACTIONS ON INDUSTRIAL INFORMATICS, VOL. 19, NO. 1, JANUARY 2023
Fig. 5. Comparison of accuracy and F1 score for the classifiers with 14- and five-feature flow-based datasets.
Fig. 6. Time overhead measured for training and testing processes for 14- and five-feature flow-based datasets. (a) Training times.
(b) Testing times.
TABLE VIII
RESULTS OF TEN-FOLD CROSS-VALIDATION OF THE FIVE-FEATURE FLOW-BASED DATASET
score remained above 99%. Furthermore, Fig. 6 indicates that the dataset (Table VII), notice that the difference in accuracy and F1
training and testing times were significantly shorter compared score between RF and XGB is minimal. However, as one of our
to the 14-feature dataset. research goals is to produce an efficient system, we consequently
For the ten-fold cross-validation, Table VIII shows the mean used XGB, as it has the best combination of high accuracy and
and standard deviation of the accuracy and F1 score for the five low testing time.
classifiers when applied to the five-feature flow-based dataset. For this classifier, the measured FPR was 0.96% for the
As shown in the table, the performance of XGB, RF, and DT packet-based classifier (Table IX), whereas the FNR was
is consistent with the results previously obtained. In addition, 0.61%. The flow-based classifier had a lower FPR of 0.26%
all the classifiers had a low standard deviation. This proves that and a lower FNR of 0.40%. These low rates indicate that, in
these classifiers can generalize well beyond the training dataset. comparison to previous approaches, both classifiers performed
very well with a low number of features extracted from captured
traffic.
D. Classifier Selection Figs. 7 and 8 show the confusion matrix plots for the
From the results of the classifier pipeline for the nine-feature XGB classifier using nine-feature packet-based dataset and
packet-based dataset (Table IV) and the five-feature flow-based five-feature flow-based dataset, respectively.
Authorized licensed use limited to: UNIVERSITY TEKNOLOGI MALAYSIA. Downloaded on February 13,2023 at 02:58:30 UTC from IEEE Xplore. Restrictions apply.
ALANI AND AWAD: INTELLIGENT TWO-LAYER INTRUSION DETECTION SYSTEM FOR THE INTERNET OF THINGS 691
TABLE IX
COMPARISON OF THE PROPOSED SYSTEM WITH STATE-OF-THE-ART APPROACHES
VII. CONCLUSION
In this article, we presented a novel two-layer IoT IDS based
on machine learning. The proposed system examines features
Fig. 8. Confusion matrix for XGB classifier using the flow-based five
features. extracted from packets as well as from network flows. Combin-
ing these two defenses provides the maximum possible protec-
tion. In testing, the proposed system had a very high accuracy
VI. DISCUSSION AND COMPARATIVE ANALYSIS of 99.15% at the packet level and 99.66% at the flow level.
Many research studies have tried addressing intrusion detec- This high accuracy was combined with noticeable efficiency
tion in IoT devices. These studies, as we explained in Section II, improvements, namely, detection times of 0.357 µs at the packet
have mostly focused on high accuracy while ignoring barriers level and 0.410 µs at the flow level. For the packet-based
to deployment in real-world applications. This study presents a classifier, the FPR was only 0.96% and the FNR was 0.61%.
novel two-layer solution that is designed to harvest the benefits of For the flow-based classifier, the FPR was only 0.26%, while the
packet- and flow-level features. Using only the features selected FNR was 0.40%. These metrics show that the proposed system
by RFE produced a noticeable reduction in training time. The outperforms previous approaches. Our future work will focus
advantage of using RFE over other dimensionality reduction on the decentralized implementation of the proposed two-layer
solutions is that fewer features need to be captured and extracted system in the edge to offload some of the processing from IoT
in the data acquisition phase of a real-time deployment. This devices.
Authorized licensed use limited to: UNIVERSITY TEKNOLOGI MALAYSIA. Downloaded on February 13,2023 at 02:58:30 UTC from IEEE Xplore. Restrictions apply.
692 IEEE TRANSACTIONS ON INDUSTRIAL INFORMATICS, VOL. 19, NO. 1, JANUARY 2023
Authorized licensed use limited to: UNIVERSITY TEKNOLOGI MALAYSIA. Downloaded on February 13,2023 at 02:58:30 UTC from IEEE Xplore. Restrictions apply.