# Multilayered Network Model for Mobile Network Infrastructure Disruption
## 4 Routing in MNM
### Routing in WSN Layer
To address this problem and also lower the traffic load in the MANET layer, WSN sink node will forward only urgent data to MANET layer when AP is not accessible. In order to lower processing on WSN gateway or sink node respectively, the process of urgent data evaluation is running on all nodes. When AP is not accessible and data are evaluated as non-urgent, nodes drop the data. Urgent data are transferred to the WSN gateway, which looks for an available MANET node. If the MANET node is accessible, data are transferred to the MANET layer, otherwise, data are processed by Data Backup algorithm described by Algorithm 1. ```
input :Data from NodeID\(\rightarrow\) DataID ifDataID is not Repository? then ifPrevious DataID from NodeID in Repository?then  Detete previous DataID in Repository  end if ifAP isaccessiblethen  sendData\(\rightarrow\) AP  Status\(\leftarrow\) Succesfull  Return:Status else  DataID\(\rightarrow\) Repository  set:\(\mathit{TimerID}\leftarrow\) time  Status\(\leftarrow\) Continue  Return:Status  end if else ifTimerID==0 then  Delete\(\mathit{DataID}\) in Repository  Status\(\leftarrow\) Fail  Return:Status else ifAP isaccessiblethen  sendData\(\rightarrow\) AP  Status\(\leftarrow\) Succesfull  Return:Status else  Update\(\mathit{TimerID}\)  Status \(\leftarrow\) Continue  Return:Status  end if  end if  end if  end if
```  
**Algorithm 1**Data Backup algorithm for storing urgent data  
A data backup algorithm is used to prevent dropping of urgent data if the MANET node is not available at the specific time for WSN gateway. The main idea is to store urgent data for a specific time. The node then waits for the MANET node or AP availability. If the time for giving data runs out, urgent data are dropped. We assume that input data can be identified by its origin node with a unique ID. Then the input data are associated with the node's ID and marked as \(\mathit{DataID}\). In the beginning, \(\mathit{DataID}\) is checked, if the gateway node has an entry for the same data in the repository. If not, the algorithm then checks, if the gateway has an entry for input data from the same node according to its ID. If yes, it means that the gateway node obtained fresher data from the same node. Therefore, older data identified by the same node are deleted. Then the gateway node tries to access AP and if this attempt is successful, the algorithm returns the \"Successful\" status of the main algorithm. If AP is not accessible, then \(DataID\) is stored to the repository and associated with \(\mathit{Time}ID\). This timer refers exactly to the stored \(DataID\). Then the algorithm returns \"Continue\" status to the main algorithm. If the gateway node has \(DataID\) stored in its repository, the algorithm checks if \(\mathit{Time}ID\) is equal to zero. If yes, \(DataID\) is deleted and algorithm returns \"Fail\" status to the main algorithm. Otherwise, the gateway node attempts to access AP and the main algorithm returns \"Successful\" status to the main algorithm if AP is available. If AP is not accessible, \(\mathit{Time}ID\) is decreased and \"Continue\" status is returned to the main algorithm.