# Reliable Link Level Routing Algorithm in Pipeline Monitoring Using Implicit Acknowledgements
## 3 Proposed Algorithm
### Algorithm Implementation  
Each node includes four buffers (_buffer\({}_{tx}\)_, _buffer\({}_{rx}\)_, _buffer\({}_{ok}\)_, and _buffer\({}_{all}\)_) and will always check if the received frame is stored in one of them to perform the appropriate actions. _Buffer\({}_{ok}\)_ stores the transmitted frames that have successfully arrived at the destination node; _buffer\({}_{tx}\)_ stores the transmitted frames from which a successful transmission has not been confirmed; _buffer\({}_{rx}\)_ stores the frames received; and _buffer\({}_{adi}\)_ stores the frames that have been sent by an adjacent node. The node \(v_{j}\) is adjacent to node \(v_{i}\), when \(\left|j-i\right|\leq 2\). As shown in Figure 2, the transmitting node \(v_{i}\) is called TXN, node \(v_{i+1}\) is called INTN (intermediate node) and node \(v_{i+2}\) is called RXN (reception node). When a TXN node transmits a frame, a _timer\({}_{tx}\)_ is started. When an INTN node receives a frame, it starts a  
Figure 1: Linear Wireless Sensor Networks. \(timer_{int}\) whose minimum value is equal to the time necessary for the RXN node to receive and retransmit the frame. When the node \(v_{i}\) detects an event, it sends information to the control center, acting as a TXN node, transmitting a broadcast frame. When node \(v_{i+2}\) receives a broadcast frame with flow \(P_{r}\) (towards \(v_{n+1}\)) and if source address is \(v_{i}\), the node \(v_{i+2}\) it will work as a RXN node. The frame will include the variable _FailN_ that will have been activated if the node \(v_{i+2}\) fails, and the variable _Changel_ that indicates a change in the data flow; both variables are initialized with \"FALSE\". There are two options to acknowledge the reception of the frame by the RXN node: using explicit ACKs (eACK) or implicit ACKs (iACK). In the first case, when the RXN node successfully receives a frame from TXN, it responds with an ACK, as shown in Figure 3. This approach increases the usage of energy (to explicitly transmit the ACK) and may even increase the latency if we wait for the ACK before transmitting a new frame. In 802.15.4, the additional time that node \(v_{i}\) must wait to transmit another frame when an ACK is used is defined by the time to pass from transmission mode to reception (TTA), the duration time of the ACK frame (which involves the additional back off time in the node \(v_{i}\) associated with the retransmission of the frame to the \(v_{i+2}\) node), and the time for the Clear Channel Assessment (CCA). Nevertheless, when the RXN node sends again the frame towards the destination (\(v_{n+1}\)), the nodes in the surrounding (\(v_{i}\), \(v_{i+1}\), \(v_{i+3}\) and \(v_{i+4}\)) will receive the information. Therefore, TXN will know that its frame has arrived at node \(v_{i+2}\) because it has retransmitted it. This works as an implicit acknowledgment (iACK) of the frame sent by node \(v_{i}\) and avoids the need for the transmission of an ACK from \(v_{i+2}\) (RXN), as shown in Figure 4.  
In order to summarize, Figure 5 presents a typical scenario. When node \(v_{i}\) detects an event, its objective is to transmit this information to the central station, so it transmits the broadcast frame to the node \(v_{i+2}\), and the node \(v_{i+1}\) also receives the frame. The node \(v_{i}\) stores the frame in _buffer\({}_{tx}\)_. Nodes \(v_{i+1}\) and \(v_{i+2}\) store the received frame in _buffer\({}_{rx}\)_ and \(v_{i+2}\) also verifies if it comes from an adjacent node to store it in _buffer\({}_{aj}\)_.  
Figure 3: eACK. Figure 2: Node identification. The frame retransmission from node \(v_{i+2}\) to node \(v_{i+4}\) is also received by nodes \(v_{i}\), \(v_{i+1}\) and \(v_{i+3}\). When \(v_{i}\) receives the retransmission from node \(v_{i+2}\) to node \(v_{i+4}\), it checks if the frame is stored in one of its buffers. If it is stored in _buffer_\({}_{tx}\), the node concludes that its transmission was successful without the need of an ACK from \(v_{i+2}\), so it stores the frame in _buffer_\({}_{ok}\) and eliminates the _buffer_\({}_{tx}\) frame.