# Formal Modeling and Improvement in the Random Path Routing Network Scheme Using Colored Petri Nets
## 3 Material and Methods
### Hieratical Colored Petri Nets
#### 3.1.1 Route Finding  
The input for the route finding module is the empty list. The route finding module transverses all the routes one by one and calculates the distance between all routes, as shown in Figure 3. It generates a list that contains the calculated distance in integral form.  
\begin{table}
\begin{tabular}{c c c} \hline  & **Color Set** & **Description** \\ \hline
**COL1** & Closet li = list INT; & The color set li defines the List of Integers. The places having the datatype li contains the list \\ \hline
**COL2** & Closet PRIOR = list INT; & The color set PRIOR defines the list of integers. The places contain the token values. \\ \hline
**COL3** & Color set PRIORITY = INT; & The color set PRIORITY contains the integer values of the tokens. \\ \hline
**COL4** & Color set rewind = product li * PRIORITY; & The li and PRIORITY belong to the color set the rewind. It contains the values of the product of li and PRIORITY. \\ \hline \end{tabular}
\end{table}
Table 1: Variable declaration for color set.  
\begin{table}
\begin{tabular}{c c} \hline  & **Variables** & **Description** \\ \hline
**V1** & Var y:revind & The variable y belongs to the color set the rewind. It holds the values of the rewind color set \\ \hline
**V2** & Var p & The variable p holds the values of the priority value. \\ \hline
**V3** & Var xli; & The variable x belongs to the Color set li. It holds the values of all list elements. \\ \hline \end{tabular}
\end{table}
Table 2: Variable declaration for system.  
Figure 2: Hieratical Colored Petri Nets.  
Token Passing: The input for the passing token module is the list of calculated paths' distance. The token can be fired to any of the calculated distances, and the distance of the route would be already known.  
Figure 4 below shows the transfer of data from a source node to a sink node. Here it can be seen the distance between the nodes. There is more than one path for packets to go from source to destination. A problem arises when the system selects the longest paths again and again, causing an increase in the computational cost.  
The random path routing is explained in Figure 4. Figure 4 shows that it has a source node and sink nodes N and N6, respectively. Suppose the token is fired from node N to node N1 by passing through the transition named as \"a.\" As the token fires the transition, it will calculate the distance by the variable R, which is 2: R. This means the distance between the nodes N and N1 is 2. While moving forward from N1 to N2, the weight between the nodes N1 and N2 is 7. The model has added the weight of the following distance to the list. So cumulatively, there are two distances on the list. The distance between N2 and N3 is 13. So now the list values are 2, 7, and 13. Moving forward to the next node list value for N3 to N4 it is now 2, 7, 13, and 5. The model has created a list of all calculated distances from a source node to a sink node. The routes' distances go from a source node to a sink node to fire the token. Moving forward, we have the following two options now: one to send the message from the same route as the system has sent it already, or to send it from any other route. A simple message sent that does not contain the critical information can be sent along the same route, the shortest route. However, if it has critical information to send, the system can send it on its own considering its computational power.