# Adaptive Thermal-Aware Routing Protocol for Wireless Body Area Network
## 3 Proposed Method of ATAR
### Data Transmission Phase  
In the previous phase, each node in the network is follows its own ring level and data are ready to be forwarded to the sink. In the proposed protocol, relay node is used for sending the data rather than using direct communication from source node to destination to reduce the overhead of the temperature rise of node. The data packet is broadcasted by source node with its ring level, as shown in Figure 12a.  
When the data packet is received by relay node, it compares its ring level with the received packet's ring level. If the data packet ring level is less than the received packet ring level, then relay node further verifies selected ID of the received data packet, with its own ID. If the ID of the data packet is matched with the ID of the relay node then, it will receive and rebroadcast the data packet otherwise discard it. This process continues until the packet reaches to the sink node as shown in Figure 12b.  
If the ring level value of neighbor node is greater than the ring level value of data packet received, then the neighbor node will keep ID, temperature of the source node and will discard the packet. Next time, this saved information will be used by the node in an intelligent way to select the next hop to forward the data packet.  
The nodes with the least rank value have the highest priority of selection as a next hop for the source node. The rank value evaluated for the selection of the forwarder node is based on the following Equations (5)-(7).  
\[R_{TN}=min(N_{T})forallnodes \tag{5}\]  
\[R_{AN}=R_{TN}forallnodes \tag{6}\]  
\[O_{N}=min(R_{AN}) \tag{7}\]  
where \(R_{TN}\) represents the rank and the value given to the temperature of each node. \(R_{AN}\) is the rank value given to each node for the selection criteria that is based on the rank value of temperature as a constant. Finally, the node with the minimum rank value is declared as \(O_{N}\), the optimal node. The format of the data packet in data transmission phase is shown below.  
Figure 12: ATAR: Data Transmission Phase.  
The Source ID is the ID of the node which broadcasts the data packet, Destination ID shows the destination address and Temperature represents the temperature of the sender node. Similarly, Selected ID is the address of the selected relay node (the optimal node).  
Furthermore, Data field represents the sensed data that the sensor node is required to send to the destination. The algorithm of the Data Transmission phase is described in Algorithm 2 and the respective flowchart is shown in Figure 13.  
Algorithms 3 and 4 present the mechanism of selection of Optimal Neighbor Node and a unicast packet with its own ring number. If the sender ring number is greater than current node's ring number and if the current node is sink then the packet will be processed otherwise Rebroadcast the packet with updating the \(senderlevel=CurrentLevel\).  
Figure 13: Flow chart of data transmission phase.  
```
1:global variables
2:\(Integer\)\(Ringlevel\)
3:\(Integer\)\(OptimalNode\)
4:\(Packet\)\(P\)
5:\(OptimalNode\)\(\leftarrow\)\(SelectNeighbor(NeighborInfo[i])\)
6:\(Packet\)\(\leftarrow\)\(PacketP()\)
7:end global variables
8:UpdateNeighbor(NodeIP,NodeTemp,PktRingLevel)
9:\(P\)\(\leftarrow\)Route(OptimalNode)
```  
**Algorithm 2** Data Transmission Phase.  
```
1:global variables
2:\(NeighborInfo\)\(nbr\)
3:end global variables
4:SelectNeighbor(NeighborInfo[size])
5:for i from 0 to size-1 do
6:\(NeighborInfo[i].rank\)\(\leftarrow\)NeighborInfo[i].temp
7:\(nbr\)\(\leftarrow\)NeighborInfo[0].temp
8:\(nbr.ip\)\(\leftarrow\)NeighborInfo[0].ip
9:\(nbr.rank\)\(\leftarrow\)NeighborInfo[0].rank
10:for i from 0 to size-1 do
11:if\(nbr.rank\)\(=\)Neighbor[i].rank then
12:\(nbr.id\)\(\leftarrow\)NeighborInfo[i].ip
```  
**Algorithm 3** On Receiving Data Packet.