# Gateway-Assisted Retransmission for Lightweight and Reliable IoT Communications
## 3 Gateway-Assisted CoAP (GaCoAP)  
In this section, we introduce our main idea with the procedure of our scheme. Then, we briefly describe the RTO computation applied in our mechanism. In our architecture, we consider a star topology, which means that each device connects to the gateway directly. The gateway is a transparent gateway between IoT devices and the server. In order to apply dynamic RTO, we consider that the gateway computes the RTO for the devices, connecting to it instead of computing by the devices themselves. Moreover, the devices can overhear the RTO values of other devices when they need to monitor the channel to ensure that the channel is idle before transmitting a packet. The devices overhearing from this method may consume only a little extra power. However, the devices can obtain an appropriate RTO earlier by overhearing. Since the network status is similar for every device in the same wireless sensor network (WSN), the RTO value calculated by the gateway reveals the latest RTO of the WSN. If a device does not transmit data for a while, it can still update its RTO by overhearing. Having the latest RTO value reduces the data retransmission, which causes considerable power consumption. Note that, when no data is to be transmitted, repetitive overhearing may cause significant extra power consumption. Therefore, in our design, the devices overhear the RTO values only before they transmit packets. When the device publishes the first message, the default RTO is set to 2. Once an RTT is measured by the device, RTO is recalculated for the next message. GaCoAP also adopts RRP policy when sending a message. Figure 3 shows the procedure of our scheme with the following steps:  
1. The RTT is updated upon the receipt of the previous ACK and stored in the device for further use. 2. When the device publishes a new message, the RTT information is contained in the message and delivered to the gateway. 3. The gateway retrieves the RTT information to compute the RTO for the device and stores the RTO value in itself. After that, the gateway removes the RTT information from the message. 4. The gateway forwards the message to the server. 5. If some subscribers have registered the corresponding interest, the server forwards the message to them. 6. The server sends an ACK as a response to the device. 7. Before the gateway forwards the ACK to the device, it puts the RTO information into the ACK. 8. The gateway returns the ACK to the device. At the same time, the gateway broadcasts this RTO to other devices. While some devices are monitoring the downlink channel right at that time, they can receive the RTO information. If the coming RTO is larger than the one kept in it, it updates the RTO by the new one. If the devices are not monitoring, they just omit this information. 9. The device configures the RTO value and updates the RTT. Finally, based on CoCoA, the RTOs are classified into strong RTOs and weak RTOs. The gateway retrieves the RTT information that contains the RTT value and the retransmission flag. If the retransmission flag is set up, the gateway adopts the weak RTO. Setting up the flag means that the RTT is obtained after at least one retransmission. On the other hand, the strong RTT is adopted if the ACK is received after the first transmission (i.e., there is no retransmission). The variables SRTT and RTTVAR are calculated as Equations (1) and (2) if the RTT is measured during the first time, or Equations (3) and (4) are applied. Then, the RTO is updated by Equations (6) and (7), and the VBF in the back-off mechanism is as Equation (9). If the RTO value is not updated for 30 s, we use Equation (8) as the aging function. In our design, we only have one GaCoAP relation, which is between the device and the server. In other words, there is no GaCoAP relation neither between the device and the gateway nor between the gateway and the server. The gateway is only in charge of RTO calculation and forwarding the messages between the device and the server.