# Rogue Node Detection Based on a Fog Network Utilizing Parked Vehicles
## 4 The Rogue Node Detection Scheme  
### The Basic Idea of the Scheme  
This paper detects rogue nodes according to the speed of the mobile vehicle. The basic idea of the proposed scheme is described as follows. Firstly, for each moving vehicle (such as vehicle \(i\)), when it enters the road segment where a parking cluster is located, it periodically sends a beacon information, which includes its vehicle ID and the vehicle's speed, to the nearest fog node \(j\). Fog node \(j\) collects beacon messages from moving vehicle \(i\) and calculates the average moving speed of vehicle \(i\), which is then sent to the central computing node for further computation. Secondly, for vehicle \(i\), the central computing node further calculates its final average moving speed according to the speed value from different fog nodes. The central computing node then divides the average speed of all vehicles into three categories based on the K-means algorithm [28; 29]. The information of the high-risk mobile vehicles is then delivered to fog nodes so that fog nodes can simultaneously perform the rogue node detection to speed up the whole detection speed. Thirdly, the U-test method is adopted to judge the rogue vehicles. After determining rogue nodes, the fog node broadcasts the ID numbers of the rogue nodes to other moving vehicles on the road segment through V2V communication. In addition, the fog node also sends the bad nodes' information to the cluster head. The cluster head sends the rogue nodes' information to other clusters on the road to inform other moving vehicles on the road to make a response to rogue nodes. The whole process of the scheme is shown in Figure 6 and the pseudocode of the scheme is shown in Algorithm 1.  
```
Procedure: The parked vehicles form a parking cluster, the cluster head dynamically creates a fog network according to the parking prediction model and each moving vehicle sends a Beacon message to the nearest fog node.
1 While(_j_ get Beacon of i) do
2 Calculate the average speed of _i_: \(V_{i,j}\)
3 If(U-test failed) then
4 Mark i as a High-Risk node
5 end if
6 end while;
7\(j\) send \(V_{i,j}\) to central computing node C
8 While(C get message of _j_) do
9 Update: \(V_{i,j}\),\(\rho\),\(\iota\)V\(avg\), \(c\)
10 Divide all speeds into three categories and check the three categories based on U-test
11 If(U-test failed) then
12 Mark all vehicles of the categories as High-Risk nodes
13 end if
14 Send every High-Risk node to idle fog nodes firstly
15 end while;
16 for all idle fog:
17 If(U-test failed) then
18 Mark the vehicle (example: _k_) as a rogue node
19 Send rogue node message of \(k\) to C
20 end if
21 While(C get rogue node message of _k_) do
22 Remove \(k\) from history speed data
23 Update: \(V_{avg}\) and \(c\)
24 Send rogue node message of \(k\) to the next cluster
25 end while;
```  
**Algorithm 1**Rogue Node Detection  
In Algorithm 1, line 1 to line 6 aims to calculate the average speed of each moving vehicle. In line 7 to line 15, the central computing node summarizes the speed information, updates the speed standard deviation and divides the speed into three categories. Then, the U-test is used to determine whether nodes in each category are high-risk or not. In line 16 to line 20, the central computing node distributes high-risk nodes to each fog node, which further determine whether each node is a rogue node or not through the U-test method. In lines 21 to 25, the central compute node summarizes the rogue node information and sends it to other nodes in the fog network and adjacent parking clusters, respectively.