# Traffic-Aware Secured Cooperative Framework for IoT-Based Smart Monitoring in Precision Agriculture
## 3 Material and Methods
### Fog Systems-Based Security Maintenance  
In the proposed framework, the fog nodes performed the role of the intermediate system between the data originating network and cloud services. Firstly, it received all the data and stores it in memory for further analysis and processing. It then confirms the data authenticity to forward it towards the cloud system in the multi-hop discipline. Then, the aggregated data \(D_{A}\) is encrypted \(En\) using the secret key \(k\) of the node \(i\). Additionally, it is integrated with the identity \(ID_{i}\) as given below. \[En(k)\ (D_{A}\textit{+}ID_{i}) \tag{6}\]  
Upon receiving, fog nodes decrypt it to retrieve the aggregated data and the identity of the data-originated node. After the decryption process, the fog nodes verify the identity of the nodes with their stored information, and if it matches positively, then it will look up its routing table for the selection of the next hop among the neighboring fogs. Moreover, the cloud system \(c\) authenticates the receiving data using digital signatures. To achieve this, the fog node \(FG\) first digitally signs the aggregated data \(D_{A}\) using its private key \(p_{r}\) to generate a secret value \(S\), as given below. \[FG_{c}=S+D_{A} \tag{7}\]  
where  
\[E_{p_{r}}(D_{A})=S \tag{8}\]  
On the other side, the cloud system first authenticates the digital signature using the public key of the fog nodes and upon successful verification, it is further forwarded to the connected end users with the IoT system. The flow between the developed techniques for intelligent agricultural routing is shown in Figure 3. Initial routes are formulated using the \begin{table}
\begin{tabular}{c c c c c} \hline
**1 Byte** & **1 Byte** & **1 Bit** & **2 Bytes** & **1 Byte** \\ \hline Node identity, _id_ & Transmission power \(t_{x}\) & Flag value, \(f_{i}\) & Score, \(sc_{i}\) & Distance to fog nodes, \(Df_{i}\) \\ \hline \end{tabular}
\end{table} 
Table 1: Format of a routing table. greedy method and exploited for optimizing the routing process. It can detect redundant nodes in the proximity of a predefined radius and accordingly, it sets the flag value by exploring the intelligent technique of machine learning. The flag value indicates the status of neighbors and whether they can transmit the data or keep them in silent mode. Finally, agricultural data is transmitted towards the sink node using the fog-based IoT system. Figure 4 explains the security algorithm for transmitting agricultural data with the support of fog nodes. It clarifies the fog-based trust mechanism with privacy concerns and reliability. Accordingly, the proposed security algorithm decreases the probabilities of network attacks and stabilizes the communication system. Fog nodes are utilized as a bridge to facilitate both the IoT and cloud systems. Firstly, fog nodes verified the incoming agricultural data, and upon its validation, authentication and session agreement are established. The session agreement is valid for a particular time and needs to be refreshed later for further communication. In case verification is unsuccessful, then the error message is generated towards the data originating node. Additionally, fog nodes construct routing paths for data forwarding by exploring the routing table. The routing information is updated and evaluated each time that data transmission is needed. In the end, fog and cloud ensure data security using cryptography-based digital signature and encryption techniques. Such a technique provides high-level security measures to the upper layers. Figure 4: Flowchart of the proposed security algorithm. Figure 3: Developed methods for the proposed framework. Moreover, the functioning of the proposed framework consists of many states, as depicted in Figure 5. The system will be in a specific state at a given time, and it will change states when a particular trigger is called. The objectives of the states are defined below. * _Sensor's deployment:_ In this state, agriculture nodes are randomly dispersed in the targeted area.