# Time and Energy Efficient Relay Transmission for Multi-Hop Wireless Sensor Networks
## 3 Proposed Scheme
### The Data Transmission in the Proposed Relay Scheme  
Figure 17 shows a timing diagram for the proposed relay scheme from an end device to a PAN coordinator.  
In Figure 17, if an end device gets a data frame, its higher layer sends a MAC Common Part Sublayer (MCPS)-DATA.request message including a sensing data and an address of the PAN coordinator to a MAC layer. When the MAC layer of the end device receives the MCPS-DATA.request message from the higher layer, it searches its relay table. If there exists the address of the PAN coordinator in the relay table, it adds the PAN coordinator address to the addressing fields in a MAC data frame. Figure 18 shows the format of the proposed MAC data frame.  
As shown in Figure 18, we add a relay address field to the addressing field for the proposed scheme. The relay address field is utilized to select the coordinator to relay a data frame. The MAC layer of the end device sets the relay address field to the address of the coordinator and the destination address field to the address of the PAN coordinator. Then, it transmits the data frame to the coordinator. When the coordinator receives the data frame from the end device, it transmits an acknowledgement (ACK) frame to the end device. When the MAC layer of the end device receives ACK frame, it transmits an MCPS-DATA.confirm message to the higher layer of the end device.  
Figure 17: The timing diagram for the proposed relay scheme from an end device to a PAN coordinator.  
Figure 19: The flow chart for the proposed relay scheme.  
Figure 18: The format of the proposed MAC data frame.  
After receiving the data frame, the MAC layer of the coordinator ascertains if the relay address field in the data frame indicates its address. If the relay address field in the data frame is equal to its address, it searches its relay table to find the coordinator related to the destination device. Then, it adds an address of the selected coordinator to the addressing field. In Figure 16, because the next device is the PAN coordinator, the coordinator set the relay address field to the PAN coordinator address and transmits the received data frame to the PAN coordinator. Following receipt of the data frame, the PAN coordinator transmits the ACK frame to the MAC layer of the coordinator. The MAC layer of the PAN coordinator ascertains if the relay address and the destination address fields in the data frame indicates its address. If the relay address and the destination address fields are equal to its address, the PAN coordinator transmits the MCPS-DATA.indication message to the higher layer. Otherwise, it discards the received data frame. Figure 19 shows the flow chart for the proposed relay scheme.  
As shown in Figure 19, when the coordinator powers on, the MAC layer of the coordinator receives MLME-SET.request message set the RelayFunction parameter to 'TRUE' from its higher layer. The MAC layer, after receiving the MLME-SET.request message, activates relay function and constructs a relay table.  
When the coordinator receives a frame from its higher layer or other devices, it ascertains a message type. If it receives the MCPS-DATA.request message from its higher layer, the MAC layer searches the relay table. And then, after it adds the relay address to the addressing field, it transmits a data frame to a relay device.  
If the coordinator receives a frame from other devices, the MAC layer ascertains if the relay address field and the destination address field in the received data frame indicates its address. If the values of the relay address field and the destination address field are equal to its address, it constructs the MCPS-DATA.indication message and transmits it to its higher layer.  
If the value of the relay address field in the received frame is equal to the coordinator address and the value of the destination address field is not equal to the coordination address, the MAC layer selects the relay coordinator and transmits the received data frame to the selected device.