IoT-based smart environment using intelligent intrusion detection system

One of the most basic characteristic features of every smart device in a network based on the Internet of Things (IoT) is to gather a larger set of data that has been created and then transfer the gathered data to the destination/receiver server through the internet. Thus, IoT-based networks are most vulnerable to simple or complex attacks that need to be identified in the early stage of data transmission for saving the network from these malicious attacks. The chief goal of the proposed work is to design and form the intelligent intrusion detection system (I-IDS) using the machine learning models such that the attacks can be identified in the IoT network. The model is built considering the normal and malicious attacks on the data that are generated in IoT smart environment. To simulate such a model, a testbed is built where a wireless router, a DHT11 sensor, and a node MCU are being used during the design phase. An attacker or adversarial system is built to perform poisoning and sniffing attacks using a laptop system. The node captures the sensor values and transmits the data to the ThinkSpeak platform, during the normal phase via the wireless gateway, and in the attack phase, the malicious attacker interprets the data, modifies it while transmitting from node to the ThinkSpeak server. Thus, the attack called Man-In-The-Middle (MITM) is performed and classified as abnormal data. Various machine learning algorithms are performed on the data, and finally, the results obtained using a probabilistic model called as Markov model have a high performance evaluated based on the I-IDS IoT network. The results obtained during the experimental analysis show that the Markov model has obtained a 100% detection rate and 19% of false alarm rate (FAR) with high precision and low error rate. The algorithms such as naïve Bayes classifier, support vector machine (SVM), decision tree, and Adaboost are considered in comparison with the Markov model. The optimal solution is obtained concerning other evaluation metrics like sensitivity, F1, and true-positive rate (TPR). Therefore, the integrated network of IoT-WSN with its performance metrics is tabulated to show the potentials of securing a network system. Additionally, the proposed work gives a high level of security for IoT smart environment as compared with the other machine learning algorithms using the novel technique of intelligent IDS.

and interconnected to process, gather, exchange, and refine meaningful data via the Internet. The IP addresses are assigned to such objects, respectively, for identities of devices and thus can transmit and receive the data through a network with no single assistance of a human. Subsequently, the IoT network is moving nearer to the reach of common people which is utilized in their daily lives. This also improves many ways of performing the daily tasks using smart IoT devices as well as the respective applications; however, this universal development raises the related security. Everything is getting smarter in the paradigm of IoT, and among all such devices, a common thing is the control of being connected through the internet. This shares the information that is sensed and consequences with the devices as they may be controlled remotely, since IoT is considered as the assembly of heterogeneous devices that need a common platform for the nodes to communicate with one another (i.e., using a protocol/rule). Therefore, this necessity provided creation to the frameworks of IoT so that the type of architecture of IoT-based framework is utilized for the particular application due to the security norms for IoT, which is still to be finalized. As the idea of IoT came into the existence, several bondholders have developed different types of frameworks based on their respective vision, which comprises ''Azure Suite of IoT by Microsoft, ARM bed by ARM and partners, HomeKit by Apple, Amazon's AWS IoT, Brillo by Google, Calvin by Ericsson, and SmartThings by Samsung'' (Ammar et al. 2018).
IoT and WSN are considered as the social reorganizers of the society, which can change the entire world into a smart-based planet. The networks with wireless sensors and IoT have various types of applications; however, most of the concepts of the network based on IoT are obtained from the sensor networks. Both the networks have similarities as well as dissimilarities. The similarities they have in both the networks include the time of sensing devices, which are resource-constrained with limited transmission capabilities, memory, and limited processing power, and also both the networks are very much powerful for the applications in real-time like surveillance of the broader area in which 24 9 7 h of observation is needed. In the situation which is hazardous and where the intervention of human is not viable, the number of sensor nodes may be deployed arbitrarily where few of them can stop working or malfunctioning. Thus, the routing protocol for durable and efficient, which may make the reorganization of the network as quickly as possible, is need to be designed. Due to these complications, both IoT and WSN also include few dissimilarities as in IoT networks, the sensor devices are smarter than the WSN's sensing nodes, whereas very often in WSNs, the sensor nodes only gather the sensed data, and thus, it is transmitted to the sink node. Another major difference is based on the usage of techniques of addressing through the process of routing. The techniques of IP addressing are applied in IoT networks, but in WSN, few other techniques are used for routing the packets like flat, location, and hierarchically based routings. Many frameworks available commercially for IoT are ARM Bed (Raoof et al. 2019), Amazon, Microsoft Azure IoT suite, Calvin from Ericsson, and SmartThings of Samsung, which are popularly available nowadays, which are used in applications by commercial end-users and businesses.

Applications of IoT-WSN
Here are some applications regarding WSN's combined IoT networks.

Home computerization system
The technology based on IoT is compatible with nearly all machines. In-home appliances, a system with smart automation is proposed for IoT. Many of the home-related tasks can be controlled by the users using the system with automation process in IoT anywhere in the world. These types of projects are supported in countries that have a maximum number of aged people, and the kids of such people can access the control of appliances remotely in smart homes through cell phones and help their parents (Chowdhury 2019).

Smart health monitoring-based system
Nowadays, the lives of humans get so stressful that they neglect their health by not taking care of properly. Generally, such people do not go very often for checkups; for example, IoT environments such as systems based on smart health monitoring may resolve such problems. However, it is also viable that the ''health-based sensors'' within the body of the patient can sense the reading of blood pressure (level), heartbeat, level of sugars and instantly notifies the doctor in case if the value is greater than the normal level. Therefore, in such scenarios, the sensors designed as smart devices monitor the well-being of an object (i.e., in this case, the patient) frequently and transmit the data to the cloud server that may further be able for a doctor, the caretaker, and the relatives of the patient to access via the smartphones. Therefore, the doctor can thus test the current status of the patient's health at any time and any place in the world by using such type of communication-based network (Challa et al. 2018).

Intelligent anti-burglary system
One of the key needs in the new society is security. Everyone would like to protect their company or home from different types of physical burglary. The applications for IoT-WSN can determine such problems. If an owner or a user leaves his/her home, the system of anti-theft needs to be turned on to monitor the house floors with any type of footstep on the tiles of the floor, thus sending an alarm to the alerting system. In such a case, if a malicious intruder attempts to enter the home, the scattered as well as activated sensing device detects them to be an anomaly and then transmits the consequent data to the alert system consisting of a microcontroller. This controller further makes the signal valid and activates the photographic camera to take a snap, and then, finally this information of theft is sent to the administrator of that home.

Defense system
Many novel approaches can lead to changes in the cyber defense and system engineering architectures by applying a practical implementation of artificial intelligence (AI) systems in cybersecurity (Elrawy et al. 2018). The emerging new applications of AI on ''internet-based network security (IBNS)'' in cyber defense platforms have the ability of self-adaptation. Also, the enormous rise in AIenabled attacks in cyber can cause an increase in sophisticated threats in cyber. Thus, the ongoing or future research activities need to be explored in countering the complex threats of cyber, enhancement in cyber situation awareness, and malware reverse engineering, mainly based on defense systems. The capability of computing has made it possible for more effective brute force attacks, and such computing resources have spawned the new generation with botnet armies. The tendency by the criminal enterprise has also enabled the network-connected commander's computing resources to be spawned with botnet armies by creating false wealth. Such IoT-based defense threats cause serious concern to the personnel task of security, which can protect the digital infrastructure.

Attack types in IoT and WSN
The communication environment based on WSN and IoT suffers from few potential attack types, which may be able to be carried out using an active or a passive adversary.

Eavesdropping
The act of this form of attack is also called a snooping or sniffing attack (Wazid 2017a). It occurs whenever an adversary or an attacker eavesdrops on the packets of data between two or more parties in communication. This attack is also considered to be one of the potential threats for communication using IoT and WSN.

Analysis of traffic flow
In this type of malicious attack, an attacker makes the interruption of messages and then further observes the intercepted messages to get about the type of communication that is mostly going to be carried out among different communicating teams (Wazid et al. 2019a).

Replay attack
This form of attack occurs if an attacker intercepts the transmitted messages that are exchanged and then further delays knowingly or retransmits them to the receiving group.

Man-in-the-middle (MITM) attacks
In this type of attack, a malevolent attacker acts to be an adversary and then makes an effort to update, delete, or modify the message contents before the receiving party has to be conveyed.

Impersonation attack
The actions of this malicious attacker successfully determine the identity or uniqueness of one of the legitimate parties communicating over the network, then update the transmitted user's message, and update on behalf of the sender.

Denial-of-service (DoS) attack
This type of attack takes place whenever a malicious attacker performs his/her activities being malicious that prevents the primary users from retrieving and accessing the system and its resources (for instance, data transmission from IoT and WSN sensors). Some of the DoS attacks that are hazardous in IoT-WSN are wormhole, gray hole, black hole, and sinkhole. The occurrence of such types of attacks is possible in a similar type of network simultaneously (for instance, the botnet). A few of the illustrations of D-DoS attacks include attacks such as flooding that consume network resources like bandwidth of the system that is targeted (i.e., web servers).

Malware attack
The malicious activity takes place whenever an opponent or an attacker executes the script being malicious (such as malware) within a distant system (like smart devices of IoT) to perform several unauthorized tasks. Examples include altering, deletion, or stealing information that is more sensitive and confidential as well as hijacking the shell of the communicating system. Hence, they can monitor the activities of users of the system without obtaining their respective permission. Based on the characteristics of the malware, they are classified into several different categories such as spyware (Challa et al. 2017), ransomware, Trojan horse, keylogger, virus, rootkit, and worm.

Motivation
Sometimes sensors in WSN and IoT are required to be set up in a ''hostile (unattended) environment,'' for instance, smart surveillance and security applications, where they cannot monitor the devices substantially all the time. An adversary or an attacker A can take the benefit of lack of manual monitoring; in addition, they can steal a few of the IoT-integrated sensor nodes deployed in a specific area. Based on the information extracted among the nodes captured, A can produce the adversary nodes and then deploy these nodes in the current network. Such attacker nodes can finally launch several attacks (such as wormhole, sinkhole, flooding, and Sybil) within the network. Therefore, the attacks may tend to lower the efficiency, performance, and consistency of communication. For instance, a decrease in the throughput of the network, a decline in the packet ratio, and a rise in the end-to-end delay may be experienced. Therefore, this becomes most essential for the protocols of intrusion detection to secure these types of attacks. In such work, a review of existing methods of intrusion detectionbased protocols is provided in IoT-WSN environments. Additionally, node MCU and other devices are used in the experiments conducted to obtain the overall performance of the network based on the evaluation metrics.

Problems in IoT-based WSN environments
This section discusses the subsequent problems and attacks associated with WSN and the IoT environment. Various IoT-based attacks are brute force attack, dictionary attack, MITM attack, buffer overflow, fuzzing attack, and DoS attacks. The issues related to such attacks are discussed below.

Resource-constrained
In both the IoT-and WSN-based environments, the sensor devices are used that are most resource-constrained as these devices have limited computation, communication capabilities, and limited battery. This characteristic of sensors is always an issue based on security at the device level as it cannot be affordable with complex security algorithms and also require more resources for protecting the deployed network. Therefore, a mechanism for a low power-based security level is needed to reduce the consumption of power during the detection process of an intruder. This makes the network lifetime to be prolonged further. Several techniques ) have been designed that consumes less power when detecting intruder using few of the lightweight operations.

Support for scalability without compromise in security
As the number of IoT devices in our daily lives grows, so does our security threat. This makes it very difficult to scale the IoT network without protecting it from attackers.
To build a smart city that expands the IoT network by increasing the number of heterogeneous devices, what will be added to create a smart city IoT network is being considered (Jan et al. 2019). Hence, few protocols are based on security in which slight modification is possible whenever the scaling up of network process is required. For instance, the addition of smart sensing devices without compromise in the security of the vast network is much required.

Securing the sensor mobile devices
The devices that keep changing the topology of the network need to cope with few other different protocols for security. Thus, it is quite a challenging task for the device based on mobile sensing that maintains the security with several different configurations of the network. Most of the wearable devices that monitor the location and health of human beings are available. However, being connected with different networks due to the mobility of the sensors and transmission of data to the servers in clouds is more challenging. Thus, a secure mechanism for defense has to be designed for mobile sensing devices.

Assistance for the heterogeneous network
A numerous sensing devices in an IoT environment have diverse software and hardware platforms. Such devices/ nodes have different procedures of security, which causes complexity (Chowdhury 2019) in working for a common IoT-based platform. Thus, a secure protocol needs to be designed that may be utilized in distinct devices.

Physical security of sensor nodes
IoT and WSN environments tend to physically capture sensor node attacks. In addition, when such a node is physically captured, the network tends to capture the physical form of the attack of the sensor node. Once the physical capturing of an adversary A of sensor nodes takes place, it performs an attack with power analysis such that the sensitive information can be extracted. This results in further compromise with the remaining portion of the network that impacts the performance of the network, i.e., quality-of-service (QoS) parameters, for example, efficiency, rate of packet dropping, latency, and accuracy. This needs 24 h of monitoring to secure against the brute capturing of the sensors. Thus, such type of protocols for intrusion detection can also work in case of capturing the sensor nodes. Also, the packaging based on tamper resistance may be applied to protect the captured nodes from the attack of power consumption analysis.

Nodes' localization
Collecting the information regarding the geographical or physical locations of deployed nodes randomly in sensor networks is known as the localization method. Because of the severe weather and the unfavorable conditions of the environment, the locations of the sensor nodes can be altered. Due to such environmental conditions, the entire network configuration might be also altered for this purpose; appropriate information on the location of sensors that are shifted is needed to reconfigure the topology of the network. Also, this may in turn decrease the performance of the protocol applied to the deployed system of intrusion detection. Some methods are proposed such that the issues of node localization can be resolved. For instance, the proposed mechanism combined with the machine learning technique is semi-supervised and supports vector regression to obtain the locations of the target nodes. The protocols using the semi-supervised hidden Markov model (HMM) can be designed to resolve such problems.

Faulty nodes detection
In most situations, the nodes in WSN are deployed in very harsh conditional environments in which the reach of humans is quite complex. In such an environment, few of the nodes may fail that further can disrupt the topology of the network. Thus, some routing protocols are required to overcome the problem of some of the faulty nodes. Few techniques include matrix calculus and fault diagnosis while detecting the faulty nodes. SVM classifier is one of the techniques applied to detect the faulty nodes within the network based on the kernel function. Henceforth, the requirement of such types of protocols for intruder detection that may also overcome the conditions of faulty (abnormal) nodes is said to be necessary.

Synchronization of nodes
Designing several types of protocols has become mandatory in IoT-WSN, such that clock synchronization is possible by all deployed nodes. This synchronization is needed in various types of attacks like data agglomeration, intrusion detection, power management, transmission schedule, etc. Nodes may be synchronized via various proposed methods, for instance, synchronization based on time for acceleration measurement, time synchronization for the usage of random bounded communication delays, synchronization based on counters for duty cycles in WSN and so on. Some of the machine learning techniques are used for synchronizing the nodes that perform all the associated tasks of WSN.

Related works
The authors in Wazid (2017b) have analyzed and explained the current systems of attacker detection for WSNs. They too have explained the problems related to security and also attacks in WSNs. The authors have made a comparative study based on the mechanisms of IDS for security as provided in their review work. The article Sharma et al.
(2019) explains different techniques of detection using IDS, like misuse-based, specification-based, and anomaly detection. The authors in the article have also provided the details of the IDSs, which were proposed for sensor networks based on their merits and demerits. In addition, some of the future directions were highlighted for the selection of IDS. The work provided in Pajouh et al. (2019) discusses the survey on IDS for the IoT environment. The work by the authors was conducted to categorize the trends, the scope of open issues, and the future aims in research for IoT-based networks. Therefore, the IDS was classified based on their parameters, such as detection technique, strategy for IDS location, validation, and security threat approach. The authors in Li et al. (2019) provide the details of the architecture of IoT and the related vulnerabilities of security. Additionally, they have demonstrated the studies related to phases of design and implementation of IDS in IoT. Some of the key points in the design of IDS were provided, which can be required in the future analysis.
In the article Breitenbacher et al. (2019), the authors have provided a survey on details of IDS in cyber-physical systems (CPSs), WSN, and mobile ad hoc networks (MANETs), which are most suitable for the environments based on IoT. Some of the future directions for research based on security in IoT have been highlighted. The summary of the existing reviews made along with the survey presented in this work in the domain of IDS protocols for IoT-WSN environments is tabulated in Table 1. In Wazid and Das (2017), the authors have proposed the system based on energy efficiency while gathering the data in mobile WSNs. The two phases discussed by the authors in the proposed scheme were the method of pattern recognition applied along with the K-means technique, and then, the delocalization is performed globally based on the local delocalization that is obtained. Thus, the emerging technique of pattern recognition is applied to gain good results in the performance of the set objective. The author in Alaparthy and Morgera (2018) explains the novel technique for event monitoring and management of assets in financial applications, in IoT-based network. The problem of increased data size where the data have to be stored and monitored are emphasized in the work proposed by the author. The framework is designed using a scheme of ''distributed pattern recognition'' mainly for data processing events. The authors have considered the event data as the patterns comprising of individual identifying data A brief outline of detection protocols based on the IoT environment is explained. In Sun et al. (2018), the authors have implemented an IDS with a lightweight technique such that the most common DoS attack can be mitigated in IoT, by considering the network based on resource-constrained devices. These nodes have applied the use of the rate of packet transmission, out of which 2 to 3 features were extracted such that the overall consumed time can be reduced for classifying the traffic flow. Therefore, this, in turn, minimizes the complexity and consumes the time when support vector machine (SVM) was applied to categorize and alleviate the DoS attack. But, the implemented work by the authors might not give the expected results with a steady flow of traffic. The authors have explained the implementation of a mechanism using lightweight termed as the misbehavior detection specification based on IoT-embedded CPS, in their article (Arshad et al. 2020). This mechanism detected the intruder based on the misbehavior of the current node in the network. The smart attackers may easily break down the rule-based systems. Hence, such techniques were not used, and so in the proposed method of the article, the profiler was designed to read the component and transmit the information to the fuzzy set analysis module such that the behavioral-based rules checked may be valid or not. This also confirms that the behavior rules applied were accurate based on the usage of the ''2-layer fuzzy-based hierarchical context-awareoriented Petri net (HCAPN) model.'' The authors in Wazid et al. (2019b) proposed the technique of IDS in which multiple malicious attack types that occur can be detected in an IoT network-based environment. This method developed uses two main approaches for the decline in dimensions and then reduces the number of selected features that are necessary to be utilized. This made minimum complexity based on the linear discrimination and principal component analysis. However, they have utilized the two methods of classification, i.e., naïve Bayes and KNN, to detect the malicious activities. The authors in the article Selvakumar et al. (2019) designed a signature-based collaborative blockchain IDS (SigCBIDS) for IoT networks. In these collaborative IDS, rules and signatures were identified such that the malicious activity of an intruder can be detected. Furthermore, the information was shared with the remaining nodes in the network so that their database can be updated, which in turn improves the rate of detection. However, at the same time, possibilities of internal attacks might increase due to the internal nodes that provide the malicious or fake signature and degrade the performance of the proposed collaborativebased IDS. Thus, this problem was resolved using a blockchain-based technique that utilizes a distributed database for detecting intrusions.
In Chaabouni et al. (2019), the authors proposed a lightweight host anomaly-based IDS for IoT (HAIDS-IoT) technique. It was an impeccable, device-based, proactive method that might be deployable using Linux-based platform consisting of end devices. This unique feature of this type of method was that it could be loaded into the kernel (core) of the operating system (OS) itself. This made it profitable to install HAIDS-IoT on endpoints using a bootable Linux kernel. The author in Moustafa et al. (2019) proposed an IDS using a client-based system that used anomalies to identify an intruder known as E-Spion. For an increased security level, three-layered security is considered. But the drawback is that increased security level also caused the increased overhead. In the work proposed by the author, the first module contains the name of the system and a continuously running process to isolate the malicious process, as well as an identifier with a whitelist prepared during the training phase, including comparison. Therefore, in the next phase, the ML-based classifier is trained among the generated logs in the learning phase and finally kept for observing the parameters process. The use of ML methods at the node level makes the technique very complex but has been worked effectively. In Diechmann et al. (2018), authors have proposed the IDS that operated in two phases to provide the system secured. Phase 1 uses a random neural network (RNN) model for abnormal IDS. Then, in phase 2, a new system tag was introduced during the design phase, and a specific tag was associated with a memory location in the system. However, a tag validation method was used to detect system anomalies. The authors in Sun and Yu (2020) also designed and proposed schemes of intrusion detection for detecting the routing attack concerning the environment in ''Edge-based IoT (E-IoT).'' The communication network dependent on WSN and IoT offers a wide range of utilizations, for example, smart homes, smart transportation, smart medical care, and brilliant urban areas. This sort of environment of communication requires one-of-a-kind prerequisites (Košt'ál et al. 2019); for example, preparing and admittance to information continuously. The information created by the sensors of IoT is huge and hence can be applied to enormous information checks. This information is to decide certain situations (e.g., determining future strength of a patient), and this kind of correspondence environment is additionally essential for the Internet. Along with these positions, it experiences conventional security, protection, and different problems. Table 2 explains the comparison of techniques used by different authors based on the extensive survey that has been done. The obtained detection rate when the respective techniques are applied is tabulated, and analysis is performed for a high detection rate as with the computed false alarm rate (FPR). This comparison provides information based on applications of IoT-WSN-integrated protocols.

Different architectures of IoT and WSN in smart environments
The different types of architectures concerning WSN-and IoT-based systems are explained in the sections below.

Architectures of WSN
The two designs are generally classified into distributed WSN (DWSN) and the hierarchical WSN (HWSN). These two models are described as follows:

Distributed WSN
The architecture of DWSN is represented in Fig. 1. In DWSN architecture, the infrastructure is not fixed, and also the network topology is ambiguous before the placement of the sensor nodes within the target region. The sensors are mostly positioned randomly all through the target field. Such nodes establish a multi-hop wireless-based communication among them which is infrastructure-less, and then, the data packet is routed/sent back to the source or base station (BS) node. In this architecture, either the sink node broadcasts the sensed data consisting of the request message or the source node overflows the query message within the connected network such that an optimal route can be found from the node to the sink to transmit the gathered and sensed information. It also considers the approach known as the data-centric method. Various protocols are utilized to transmit the data that is sensed to the sink node such as direct diffusion, flooding, gossiping, rumor routing, spin, energy-aware routing (Sivasakthiselvan and Nagarajan 2017) for minimum energy in ad hocbased WSN. Nevertheless, this approach is not appropriate for broad-reaching, and thus, it has an issue of the network's lifetime for a wide range.

Hierarchical WSN
The HWSN architecture is depicted in Fig. 2. In this type of architecture, the nodes establish a hierarchy based on the capabilities such as cluster heads (CHs), sensor nodes (SNs), and BS. The SNs are considered as general wireless nodes that have limited capability. Hence, the sensor devices have limited backup of battery, processing of data, low storage, and communication capability (Kiwanuka and Akhtar 1010). The process of clustering is known as an assemblage of nodes. These sensors within the cluster communicate with each other in the group and lastly communicates with the CH node. Thus, CHs are resourcerich devices and are fixed with batteries having high power, powerful antenna, processing capabilities of data, and larger storage of memory. Thus, they can implement relatively more complex numerical functions than that of sensors, as well as have a much greater range of radio transmission. CHs can connect communicating with one another directly and transmit the data packet between the cluster members and the BS.

Cluster heads
They can connect straightforwardly and send information between their gathering nodes and the BS. Several rules are used to execute this methodology (e.g., PACT, HEED, LEACH, TEEN, PEGASIS, hierarchical-PEGASIS, APTEEN (Wheelus and Zhu 2020), routing based on energy-aware for clustered WSN, and Sec route).

Architectures based on IoT
The architectures of IoT in different scenarios in smart environments where several devices are integrated with sensor nodes are discussed in the following section.

General IoT (G-IoT) architecture
The fundamental architecture of IoT includes various settings such as smart home, community, and transport. These settings consisting of different smart devices are deployed, for instance, actuators and sensors. The devices enable the daily activities of human beings. All the smart nodes are associated via the internet to a precise node/device that is known as gateway routers or nodes. The different types of operators, such as doctors, smart home users, and industrialists, are the users having an interest in data accessing of related IoT devices through GN. For the communication to be secure, a security protocol is required that performs mutual authentication between the user and sensor node through the GNs.

Cloud-based IoT (C-IoT) architecture
The CIoT architecture is depicted in Fig. 3. IoT based on cloud is an architecture with three layers composed of a gateway, cloud servers, and the collection of sensor devices. The collaboration of the IoT environment with cloud services provides the entire system valuable. The devices sense the data by communicating via wireless technology like LAN,IEEE 802.15.4,RFID,and IEEE 802.11. It allows the smart devices of sensing to develop the route from multiple sources to their respective destinations (Faria et al. 2016), in a multi-hop manner. The GN helps the communication between the cloud servers and the sensing devices. The sensed data that are collected are transmitted to the cloud-based servers for more processing through the IoT-based smart environment using intelligent intrusion detection system 11581 GN. Finally, the data packet reaches the cloud server, which in turn organizes the data transmission from the sensor to the user devices. Based on the requirement of various users, the cloud server processes the data further.

Fog-based IoT (F-IoT) architecture
The fog-based IoT architecture is shown in Fig. 4. In IoT, every object becomes smart as data generated by such objects are very large and become complex for internet infrastructure to handle them. Later, the IoT integrated with cloud computing tranquilized the network condition, but not appropriate to solve all the problems of IoT. Thus, in the year 2012, CISCO initiated the novel concept termed fog computing. This type of computing uses the functional capacity of cloud servers and finally accomplishes the data close to the IoT devices such as proxy to improve efficiency, minimizing the end-to-end delay as well as preserves the bandwidth of network topology. The two types of frameworks include fog and fog cloud devices. Therefore, in the fog device framework, the fog-based servers provide the services and hence simple operations are conducted by the fog, but complex operations are conducted by cloud-based servers. The computing-based fog executes the analysis of data close to IoT node devices, and this may be considered a situation of data analysis in real-time, which can be more susceptible to security threats.

Proposed IoT-I-IDS
The IoT network architecture is shown in Fig. 5, which depicts the connection of sensors to the node modules. The initial step for building the IoT platform is connected consisting of DHT11 sensor with node MCU module. The sensor DHT11 contains three pins: out, positive (?), and negative (-), which are in turn connected to GND, D1, and VCC pins of node MCU.

Experiment performed using node MCU and ThinkSpeak interface
The adversarial scheme is built that generates attacks in the stage of the IoT network. The wire shark is visualized and packets are analyzed that identify traffic flow and IP address in the network. The Debian OS called Kali Linux is used to generate an attack, saturation testing, and thus serves it as a system-based attacker. Figure 6 depicts the attack phase for an overall procedure that follows the designing of attacks in the experiment. The sensor data in packets are transmitted to the Thinkspeak server where it is first analyzed using Wireshark. Next, the Ettercap tool is used for ARP poisoning, and based on the application known as burp suite, the sniffed packets are altered. This datum modified is further transmitted to the cloud to a NODE MCU client. The implementation tools used are Ettercap burp suite and wire shark, which were connected on the platform of Kali Linux. Data are captured from sensors in the network and extract the features for both scenarios of normal and attack. Thus, the data are collected from the ThinkSpeak, and later data from sensor DHT11 are sent to the think speak through client from the networkbased IoT. The format for information of timestamp for the data taken in think speak is: \Timestamp, S1, S2, S3[ , whereas, the three calculated values named as due point, temperature, and humidity that are created by three stored channels. The flow of data to the think speak is then transmitted which are captured by not performing the attacks and then are categorized as standard data. The interrupted data are adapted in the burp suite, and it is labeled as attack data which are captured. The CSV format is used while downloading the data which is further used for analysis.

IoT systems designed integrated with I-IDS
Based on the condition of the IoT environment, the system can be changed which can further adapt to new attacks accordingly. Artificial intelligence models and signaturebased models are programmed. Moreover, the expected artificial solution is planned, using the process of an artificial immune system. The main goal of the framework is to design the security in the IoT networks. Thus, an intelligent IDS depends on two important theories known as self-adaptation and self-learning to the new environment. It is recommended that the detection architecture for denialof-service (DoS) attack within the network focusing on 6LoWPAN, for I-IDS check, the security manager DoS, and the Suricata IDS. The system based on vulnerabilities Fig. 4 Fog-based architecture of IoT is surveyed and is developed, which are present in WSNsbased IP. The host Mac is run on ''Suricata IDS.'' In addition, the benefit of this system is that it can solve the problem of power consumption and thus save the power resources of the WSN. DoS-based detection system with its basic components called ''frequency agility manager (FAM)'' with ''safety incident and event management system (SIEM)'' is developed. These components are organized to form the structure of control which displays the large systems.
• Security of malicious detection methods The majority of attacker location-based techniques planned for WSN and IoT are not safe as they may not give total protection from different types of attacks. In this way, it is needed to plan such kinds of intruder detection strategies that should be secured against numerous attacks simultaneously. The methods of planning can be tested because of resource-constrained sensors and other devices of IoT.
• Ability and adaptability of intrusion detection methods In the communication environment dependent on WSN and IoT, the sensors have restricted resources with limited power and capacity of battery life. Subsequently, such devices cannot perform communication, records, and computation activities that need more energy. In addition, it is suggested that different resources have to be utilized during intrusion detection. The explanation is that it can consume different resources of the device, which causes a high frequency of the battery of the sensors when sending and receiving large messages. Hence, it is required to plan IDS methods such that the proposed work has low computation, communication, and storage costs, without compromising the security of the system. WSN-integrated IoT is a sort of enormous opportunity for varied networks of different communication ideal models and applications that have their capacities and necessities. Hence, intrusion detection for this type of environment is a very difficult assignment. It may have electronic clinical records (ECRs) for specific clients that are put away on an IoT-empowered cloud worker for additional handling. Numerous devices have the advantages of the body area network (BAN) that produces information and then is sent to the cloud. Then a heterogeneous network of separate specialized devices is created, requiring special types of intruder detection that can protect a wide range of devices from this type of communication network.
• Cross-platform based detection of intruders The heterogeneity of WSN and IoT networks makes issues when arranging some IDS methods. The heterogeneity nature permits the interconnection of various IoT-based smart environment using intelligent intrusion detection system 11583 application specifications, and yet likewise makes difficulties for the plan and expert measures of IDS. For instance, whenever a smart home application accepts information from a well-being device location, detecting an intruder should be accurate and reliable such that the application should recover information from the unbiased network with no issues. In any case, it is important that more often the information is put away in the cloud, so different detection components are required. Thus, for such applications, there is a need for efficient and intruder location-based methods to give straightforward networks between various IoT stages.

I-IDS approach
The offline phase and the online phase of detection are depicted in Fig. 7, where the decision is performed by the I-IDS. The data set from the sensor is preprocessed and aggregated which is performed as input data to the I-IDS framework. The decision model of the designed detection framework classifies the data set based on the features of data and the probabilistic approached Markov model integrated within. The data set is preprocessed and analyzed during the detection phase both online and offline. Furthermore, they are classified to be labeled as normal and attack type. The experiments performed give a high detection rate for the probabilistic approach.
6 Results and performance analysis The evaluation metrics for the assessment of the efficiency of the malicious detection system is based on four parameters, such as false positive (ÿ), true positive (a), true negative (p), and false negative (b). False positive (ÿ) is a false line that indicates an intrusion without the actual presence of intrusion.
True positive (a): When an anomaly class is anticipated and is in precise order and shows the intrusion.
True negative (p): It is the alert class that does not display any of its interference.
False negative (b) is a false chain, which indicates no intrusion even if there is the presence of an intruder during access.
Thus, the true-positive rate (TPR) depicts the probability of malicious attacker detection and is evaluated as: The false-positive rate (FPR) is known as the probability of wrongly identifying the normal activity as an obstacle and thus is calculated as follows: The residual (R) that represents the percentage of several vital records in the database is obtained via a search method, which is likewise calculated as the dedicated  Fig. 7 I-IDS framework demonstration report. Furthermore, the precision (P) measures the percentage of most significant record among all the records attained, which is estimated as below: The F-score (F) is determined as the symmetry among R and P, which is evaluated as: The overall success rate, which determines the exact grouping percentage, is measured as follows: And the rate of error obtained is calculated as: The classifier's performance is measured based on its accuracy, sensitivity (recall), precision, error rate, specificity, detection rate, F1, and false alarm rate (FAR). A confusion matrix is created for each classifier that is implemented and then the performance metrics are calculated.
The two sets of independent data sampling use the hold method as generated: one set for training and the other set for examining the sample in the classifier. In this way, the training dataset is used to develop a model based on the classifier, and then, the test data is used to evaluate the metrics, known as the accuracy of the classifier. In the analysis, the classifier model is generated from 80% of the trained dataset, and the remaining 20% is used to test the performance of the classifier.  Figs. 8, 9, 10, and 11 in the simulation environment for evaluating the performance metrics with the obtained results.

Result analysis of different algorithms and its performance measures
The collected data are sent by the client to the ThinkSpeak IoT Interface server. The data are then captured in a specific format that contains a timestamp and three different channels named S1, S2, and S3 for storing measurements such as temperature, humidity, and time. Thus, the data that flow from the server are captured before performing an attack, and it is named as the normal data. The sensed data are transmitted in the comma separated variable (CSV) format and then further analyzed. The downloaded data remove the timestamp and the three features labeled using a class label are represented as normal or attack data. Thus, the data set generated consists of 480 records, and then, the performance of classifiers is evaluated with the records generated and is used for further experiments. In Fig. 10, the Markov model shows high accuracy of 1.000 when compared with other classifiers.
The evaluation of metrics is performed both for precision and accuracy versus time measured in milliseconds (ms) as one of the factors.

Confusion matrix
The comparative analysis made between all five algorithms is performed as explained with the confusion matrix drawn for the compared algorithms. The matrix is shown for all five algorithms as depicted in Tables 4, 5 , 6, 7, 8 where the data taken are about 20% out of 500 records, and among them, 90 records are considered for testing the functionality of the modeled classifier. Table 4 shows the results of the Markov model confusion matrix during data classification. In addition, it has been found that the Markov model can       data into true classes. Similarly, the other classifiers are also depicted based on the confusion matrix obtained.

Conclusion
The task will discuss security requirements and various attacks that can occur in communication environments based on WSN and IoT. It summarizes the emerging WSN protocols that are integrated with IoT is explained in brief considering different models of WSN and IoT. The IDS architecture provides a combined usage of computational complexity, and the major advantage of this kind of proposed architecture is that the detection rate is increased and high security can be provided in the IoT network with high accuracy. A taxonomy of protocols of WSN is identified, which provides the classification of protocols based on the attacks for better performance. The intelligent IDS is designed using different machine learning algorithms along with the probabilistic approach known as the Markovian model. It has been given a scientific classification of the methods for identifying intruders based on existing related communication conditions that are dependent on WSN and IoT. Besides, the study of WSN-and IoT-based location techniques is also analyzed and surveyed with various other models. Various correlations have been created. For example, detection rate, falsepositive rate, attacker detection sensitivity, etc. Finally, it is recognized and presented some future considerations in terms of intrusion detection infrastructure and other security rules for WSN and IoT. Thus, the ability to connect the devices to the internet in most applications is a critical part of things in the future. However, the protection of IoT network and their improvement is an important challenge for research, which are considered as limited resourceconstrained for the protection of IoT devices. The performed experiments show that the capability of reduced resources in a device has the rate of flow of data packets with 450 Kb per second. The performance metrics are tabulated with FAR as 19% for the proposed model, whereas, for other algorithms, the FAR is high which in turn degrades the accuracy of detection of an intruder. The accuracy for the proposed model obtained is 100% when compared with other algorithms having less accuracy. The confusion matrix is obtained for all the algorithms. However, this architecture is not applied to a large set of data. Thus, as future work, it is intended to test the proposed intelligent IDS architecture with a wider range of techniques using the novel approach. Also, the probable future work is to highlight the comparative analysis based on the larger set of data.