# Efficient Intrusion Detection Algorithms for Smart Cities-Based Wireless Sensing Technologies
## 2 Related Work  
Sensor networks are one of the bases either of smart cities or IoT networks. Therefore, many of the algorithms and techniques are proposed for better operation of the network, including clustering algorithms. The most related clustering algorithm for our work in this paper is LEACH [31; 32]. At the same time, there are many of the routing algorithms that are proposed for WSNs. However, one of the most used routing protocols is AODV. Based on our research, the LEACH algorithm makes the WSNs vulnerable to the different types of attacks, including the sinkhole. Therefore, this section describes LEACH as a clustering algorithm, S-LEACH, MS-LEACH, and ABC as sinkhole detection algorithms, and AODV as routing technique. LEACH Algorithm [31; 32]: It is a clustering algorithm designed especially for WSNs that make the routing process. Its main idea is based on the concept of energy consumption of each node. It is also a round-based technique, where cluster heads (CHs) are periodically changing to balance the network energy. Previously selected CHs cannot join the next round of selection. The algorithm divides the nodes into groups with a cluster head for each group. It works in two phases--setup and creation. In the setup phase, each node generates a number between 0 and 1. If a node selects a number less than a certain threshold (\(T\)(\(i\))), it announces itself as a cluster head for the current round. \(T\)(\(i\)) is computed as follows:  
\[T(i)=\ \left\{ \begin{array}{l}\left(\frac{p}{(1-p)\left(r\bmod\frac{1}{p} \right)}\right)if\ i\in G\\ 0\ otherwise\end{array} \right. \tag{1}\]  
where \(p\) is the desired percentage to be a cluster head, \(G\) is the node that is not selected in the 1/\(p\) round, and \(r\) is the sensor communication range. The nodes' desires could be generated randomly or based on the node's residual energy. The second phase is called steady-state, where nodes join the nearest cluster heads and start aggregating and transmitting data to their CHs. The CHs are responsible for transmitting their collected data to the sink node. After a certain period of time, the network starts another round of selection to CHs. There are many variations of LEACH, including the ones reported in [33]. S-LEACH Algorithm [23]: Since LEACH in its current format is vulnerable to different attacks. S-LEACH adds security to protect the network from insiders and outsiders. S-LEACH protects the network from outsider attackers, guaranteeing data authentication and data freshness. It borrows some of the building blocks from the SPIN [34] algorithm, where symmetric keys are used for authentication. In the pre-deployment phase, each node is equipped with a symmetric key that is shared with the sink node. Therefore, each node authenticates itself through the \"Adv\" message with the message authentication code (MAC) generated using the shared key. The same process occurs to authenticate the cluster heads. LEACH Sinkhole [35]: In the original form of LEACH, the selection of the CH depends on the signal strength; others consider the distance from the cluster heads and the CH energy. Therefore, a powerful adversary can send a message to all of the nodes on the network, announcing itself as a CH, see Figure 3. The adversary receives all of the nodes' messages and drops them all, interrupting the network's operation. MS-LEACH Algorithm [22]: It tries to enhance the security of S-LEACH, adding data confidentiality, and improving nodes to cluster head authentication. It adds another security level where a shared pairwise key between the CH and its member is established. It employs Blowfish as its cryptographic function. Therefore, MS_LEACH assumes that each node is equipped with two symmetric keys shared with the sink node, and the sink node holds the last keychain. As can be seen in the S-LEACH and MS-LEACH, they are secure in terms of authentication and confidentiality but still vulnerable to sinkhole attacks. The following is the sinkhole attack on LEACH.