# QoS Enabled Layered Based Clustering for Reactive Flooding in the Internet of Things
## 4 Proposed CBF for IoT
### The IntraLayer Clustering (IALC)
The mote then looks into their routing table to see if the desired destination mote resides inside the cluster. If yes, the mote then responds to the query source and sends back a route query reply, along with a path specified by the last hop information cached in the detected queries table. If the destination mote not reside in the mote's cluster, the mote, then broadcasts the rout query request to all the peripheral motes to search the destination mote outside the cluster. Without the appropriate query control scheme the broadcasting mote, itself, generates more control traffic as compared to flooding. The protocol is shown in Figure 6.

As discussed, the essential aim of the flooder mote is to generate unwanted and redundant routing queries to make the link busy and to stop the authentic mote from sending wanted query packets. A mechanism is required to measure the total time spent for waiting the link to be free, also to check the signal strength of the query packet and location consistency of the mote, and match these metrics to the regular time of the traffic to measure the link for redundant queries. A query control mechanism is introduced to execute these tasks. As shown in Equation (2), the proposed QCM technique uses a change in QueryLimitThreshold (QLT) for detecting and terminating the redundant and unwanted query request packets. The proposed mechanism is favorable in boosting the performance of the IoT's network in terms of signal strength of query packets, and in the improvement in location consistency

Figure 6: Interlayer cluster protocol (IELC). checking of connected motes, in this way protecting the network against reactive flooding attacks. The QLT is calculated based on Equation (2):

\[\sum_{i=1}^{n}\mathrm{Md}_{i}=P \tag{2}\]

From Equation (2), M is the maximum query request packets of neighbor motes, n denotes the net sum of motes, distances between every mote and QLT are symbolized by \(\mathrm{d}_{i}\) (\(\mathrm{d}_{i}\) is the distance between the motes that are communicating, and i is the number of respective motes, from 1 to n) and P (P is a value that determines if there is an attack on the network), respectively. The QCM technique uses link signal strength to determine the consistency of the query packet by scanning if the QLT contradicts the regular packet data transmission value. The mote that transmits the QLT is sporadically tested and matched against the present value to determine the occurrence of flooding in the network. A mote is considered a flooder if its QLT is exceeded the maximum query packet of any mote. Moreover, the mote will not be considered a flooder if its QLT value is smaller than the maximum query packet [33]. Upon detection of a flooder mote by QCM, it alerts all connected neighbor motes to switch their routing paths which lead to the flooder mote. Thereby, QCM ultimately eliminates the flooder mote from the network. The QCM algorithm is shown in Algorithm 3. ```
1:\(\mathrm{n}\), MaxQuery(M): M \(\in\) Neighbor motes
2:Input: query limit value, \(\mathrm{x}_{0}\), \(\mathrm{y}_{0}\), \(\mathrm{x}_{n}\), \(\mathrm{y}_{n}\); Output: Dist, \(\Delta\) query limit value;
3:\(\mathrm{\textbf{1:If}}\) (MaxQuery(M) \(<\) QueryLimitThreshold(QLT)) \(\mathrm{\textbf{Then}}\)
4: Check (SignalStrengthConsistancy(SSC));
5: Check (Sending QueryLimitThreshold (QLT));
6: Check-link = (SignalStrengthConsistancy(SSC), MaxQuery(M));
7:\(\mathrm{\textbf{Elseif}}\) (Check-link = Not True) \(\mathrm{\textbf{Then}}\)
8: Flooding occurred; \(\mathrm{\textbf{Endif}}\)
9:\(\mathrm{\textbf{If}}\) (MaxQuery(M) \(>\) QueryLimitThreshold (QLT)) \(\mathrm{\textbf{Then}}\)
10:\(Z_{0}=(\mathrm{x}_{0},y_{0})=\) mote_location;
11:\(Z_{n}=(\mathrm{x}_{n},\mathrm{y}_{n})=\) find_mote_location;
12: Check-link = Query Packet Sent;
13:\(\mathrm{\textbf{Elseif}}\) (Check-link = Not True) \(\mathrm{\textbf{Then}}\)
14: Flooding occurred; \(\mathrm{\textbf{Endif}}\)
15:\(\mathrm{\textbf{End}}\)
```

**Algorithm 3** Query control mechanism (QCM) algorithm.