# Reliable Link Level Routing Algorithm in Pipeline Monitoring Using Implicit Acknowledgements
## 3 Proposed Algorithm
### Pseudocode and State Diagram  
The Algorithm 1 that determines the operation of a node is presented below. All nodes that are part of the linear infrastructure will run the same code.  
Figure 8: Flow \(Pr\) interrupted.  
Figure 9: \(Pr\) and \(Pl\) flows are interrupted.  
```
1 Input:\(id\_s\) is source address,
2 Input:\(id\_d\) is destination address,
3 Input:\(Maxwait\) is maximum wait time for an iACK from of node TXN or INTN,
4 Input:\(FailN\) node is on
5 Input:\(ChangeF\) The direction of traffic flow has not change
6 if frame received then
7 if frame is stored in \(buffer_{aij}\) or \(buffer_{ok}\) then frame is discarded
8 else
9 case\(id\_s==i-1\), and \(id\_d==\) broadcast: the node is INTN, and waits iACK from node i+1:
10 case\(id\_s==i+1\):
11 case\(id\_d==\) broadcast: the node behaves as INTN and discards the frame clean \(buffer_{rx}\) and stores frame in buffer\({}_{ok}\):
12 case\(id\_d==\) unicast: (i+3 node fail) node works as TXN and retransmits the frame with \(id\_d=\) broadcast,

stores the frame in \(buffer_{rx}\):
13 case\(id\_s==i-2\) and \(id\_d==\) broadcast: behaves as an RXN node and retransmits the frame with \(id\_d=\) broadcast, store the frame in \(buffer_{rx}\):
14 case\(id\_s==i+2\) and \(id\_d==\) broadcast:
15 if\(FailN==F\)then it has received an iACK, stores frame \(buffer_{ok}\) and transmits the following frame else
16 case\(ChangeF==\) F, set \(ChangeF=\) T, transmit broadcast frame:
17 case\(ChangeF==\) T, discard the frame:
18 endif
19 endif
20 else
21 case node INTN: retransmit unicast frame to i+1:
22 case node TXN:
23 if retransmission > Maxwait. then
24 transmit unicast frame to node i-1 and set \(FailN=\) T
25 else retransmit frame broadcast
26 endif
27 endif
```  
**Algorithm 1** Pseudo-code for our proposal  
\begin{table}
\begin{tabular}{l} \hline
**Algorithm 1** Pseudo-code for our proposal \\ \hline
**1 Input:\(id\_s\) is source address,** \\
**2 Input:\(id\_d\) is destination address,** \\
**3 Input:\(Maxwait\) is maximum wait time for an iACK from of node TXN or INTN, \\
**4 Input:\(FailN\) node is on** \\
**5 Input:\(ChangeF\) The direction of traffic flow has not change \\
**6 if frame received then** \\
**7 if frame is stored in \(buffer_{aij}\) or \(buffer_{ok}\) then frame is discarded** \\
**8 else** \\
**9 case\(id\_s==i-1\), and \(id\_d==\) broadcast: the node is INTN, and waits iACK from node i+1:
10 case\(id\_s==i+1\):
11 case\(id\_d==\) broadcast: the node behaves as INTN and discards the frame clean \(buffer_{rx}\) and stores frame in buffer\({}_{ok}\):
12 case\(id\_d==\) unicast: (i+3 node fail) node works as TXN and retransmits the frame with \(id\_d=\) broadcast,  
stores the frame in \(buffer_{rx}\):
13 case\(id\_s==i-2\) and \(id\_d==\) broadcast: behaves as an RXN node and retransmits the frame with \(id\_d=\) broadcast, store the frame in \(buffer_{rx}\):
14 case\(id\_s==i+2\) and \(id\_d==\) broadcast:
15 if\(FailN==F\)then it has received an iACK, stores frame \(buffer_{ok}\) and transmits the following frame else
16 case\(ChangeF==\) F, set \(ChangeF=\) T, transmit broadcast frame:
17 case\(ChangeF==\) T, discard the frame:
18 endif
19 endif
20 else
21 case node INTN: retransmit unicast frame to i+1:
22 case node TXN:
23 if retransmission > Maxwait. then \\
24 transmit unicast frame to node i-1 and set \(FailN=\) T \\
25 else retransmit frame broadcast \\
26 endif
27 endif ```  
**Algorithm 2** Pseudo-code for our proposal \\ \hline \end{tabular}
\end{table}
Table 1: INTN node state diagram.  
Figure 10: INTN node state diagram.