# Game-Theory-Based Multimode Routing Protocol for Internet of Things
## 3 Proposed Mechanism
### Architecture and Functions of Smart Nodes
#### 3.4.2 Algorithms  
This section goes through three major algorithms. Algorithm 1 describes the technique for smart nodes to choose an initial default routing protocol. The selected routing protocol may update with the passage of time, according to the GT process. Algorithm 2 describes how to update the routing protocol. Smart nodes accept packets and conduct different tasks depending on the nature of packets received. Algorithm 3 explains this procedure. ```
Input:\(\mathbf{n_{i}}\) Output: DefaultRoutingProtocol Begin: \(With\)\(Neigh_{\text{Table}}\)\(Upldate\) Records \(Calculate\)\(\text{ThE}=\text{Med}\left(\lambda\text{E}(\mathbf{n_{i}})\right)\)\(\text{ThM}=\text{Med}\left(\text{MobRatio}\right)\)\(End\)\(With\)\(If\)\(\text{


```
1 Input:\(\mathbf{n_{i}}\) Output: DefaultRoutingProtocol Begin:
21 \(If\) CurrentTime - LastReadTime \(>\) ExpiryInterval
2\(round=0\)
3\(End\ if\)
4\(if\)\(G_{\mathrm{matrix}}=\Delta\ OR\ G_{\mathrm{matrix}}=\Delta\)P
5\(if\ round=0\)
6\(\mathrm{PP}=\) Count Distinct(ProRTable.NextHop)
7\(\mathrm{RP}=\) Count Distinct(ReRTable.NextHop)
8\(If\) (\(\mathrm{PP}>\mathrm{RP}\))
9 Return Proactive
10\(Else\)
11 Return Reactive
12\(round=1\)
13\(End\ 1f\)
14\(Else\)
15\(\mathrm{PP}=\) Count Distinct(ProRTable.DestIP)
16\(\mathrm{PP}=\mathrm{PP}+\) Count Distinct(ProRTable.NextHop)
17\(\mathrm{RP}=\) Count Distinct(ReRTable.DestIP)
18\(\mathrm{RP}=\mathrm{RP}+\) Count Distinct(ReaRTable.NextHop)
19\(If\) (\(\mathrm{PP}>\mathrm{RP}\))
20 Return Proactive
21\(Else\)
22 Return Reactive
23\(round=1\)
24\(End\ 1f\)
25\(End\ 1f\)
26\(Else\)
27 Return n\({}_{\mathrm{i}}\).DefItRProc
28\(\mathrm{LastReadTime}=\) CurrentTime
29\(End\ 1f\)
```

**Algorithm 2** Evolution Process for Default Routing Protocol

Algorithm 3 deals with packet arrival and node's operations regarding the kind of packet. Initially, a temporary variable RT is allocated to one of the routing tables. Step 9 determines whether the packet is of routing type. For a route packet arrival, actions are conducted from steps 10 to 18. The node either acknowledges the source, or broadcasts or forwards the packet during these steps. Step 20 determines whether or not the packet is a proactive TCM. The routing table is modified after the TC message is acknowledged. At step 25, the packet is checked to see if it contains data. Respective operations (steps 26-31) are performed according to the nature of the data packet. ## 4 Simulation Results

The proposed work is simulated in NS2.35. AWK scripts were used to extract the results from the created trace files, and then MS Excel was used to create the graphs. The performance metrics accessed were remaining energy, throughput, PDR, and end-to-end delays. Some scenarios were created and the results with and without smart nodes were assessed. A heterogeneous network made up of AODV and DSDV nodes was used in these scenarios. The findings are compared with and without the smart nodes. In each example the network is first examined with the absence of nodes that have the proposed mechanism. After that, the proposed mechanism's smart nodes are added to the network, and outcomes are analyzed. The duration of the simulation was 100 seconds. Table 8 lists the main simulation parameters. In four time pauses, the resultant values were recorded. ### Case 1: Nodes from Different Classes Are Deployed in Separate but Nearby Fields

Figure 8 shows a screenshot of the NetAnim animator in this scenario. The AODV nodes are green, the DSDV nodes are blue, and the proposed smart nodes are red. In Table 9, the parameters for heterogeneous nodes are listed. There are three classes of nodes, each with its own set of values. The common and uncommon communication types are considered in this example situation. In the previous section, these types were discussed. Figure 8: Case scenario 1: NS2 NetAnim Screenshot.