# RARZ: Ring-Zone Based Routing Protocol for Wireless Sensor Networks
## 3 RARZ Protocol
### Next Hop Node Selection  
In RARZ, the next relaying node is selected based on its residual energy and the ring in which it is located (i.e., ringID). Upon receiving the packet, each node having a lower ringID starts its timer. The node whose timer expires earlier is selected as the next relaying node for the received data. The timer is a function of the node's residual energy and its ringID:  
\[timer=w_{1}\times ringID+\ w_{2}\bigg{(}\frac{TE}{RE}\bigg{)} \tag{1}\]  
where \(w_{1}\) and \(w_{2}\) are the weights of the ringID and the residual energy of nodes, respectively. The values of \(w_{1}\) and \(w_{2}\) have been empirically optimized with respect to various parameters, to 0.003 and 0.001, respectively, based on the simulations conducted in OMNET++ simulator. Total energy (\(TE\)) is the initial energy of a newly deployed node and residual energy (\(RE\)) is the current energy level of the node at any particular time. The higher the residual energy of the node, the lower will be the value of the timer and vice versa. In Equation (1), ringID will play an important role when there is a node located in the next to the immediate ring. The lower the ringID, the lower will be the time attributed to the timer. This increases the chances that a node with lower ringID will be selected as the next hop. The lower number of hops reduces the average energy consumption and average end-to-end delay. The RARZ routing scheme is described in Figure 3.  
As per Figure 3, node S in ring 4 broadcasts its data packet with ringID 4. There are nine nodes in the communication range of node S to receive the packet. The nodes in its own ring, i.e., within ring 4, will delete the packet after checking the sending ringID. Only ring 3 and ring 2 nodes will start their timers as per Equation (1). If one assumes similar energy levels for all the nodes, then, in the scenario in hand, the timer of the ring 2 nodes will expire first. It will then forward the packet to the next relaying node in ring 1 and eventually the packet is routed to the BS via a node in ring 1. In this way the packet reaches BS in just three hops instead of four. When a node in ring 2 relays the packet further, rings 2, 3, and 4 will cancel their timers and discard the packet after checking the received ringID.  
In Figure 4, when node A from ring 4 sends its data packet, there are three nodes in ring 3 to receive it. After the successful reception, these nodes will buffer the packet and schedule their timers for sending it further. Based on Equation (5), the timer of node B will expire earlier and will relay the packet further, assuming that it has more energy in comparison to other nodes. The timers of C and D are killed once they observe the packet from node B with the same MsgSeqNo for which they have already been running their timers. In this way, only node B is chosen as a next relaying node.  
Figure 3: Routing scheme used in RARZ.  
The distance between any two rings is R meters (R is the transmission range of a node), and the range of the sensor nodes is set to 2R because a node at the border of any ring could relay its message to a node located at the edge of the immediate ring.