## 3 Rait
### Sliding Window  
Sliding window algorithm is a method used for flow control in network transfer. A sliding window algorithm places a queue (buffer) between nodes. The sender creates a sequence number for each packet as it is transferred. Throughout the communication, it maintains the send window size so that it does not overflow. When a packet arrives in the receiver, the sliding window size for the receiving queue is decreased. When the packets in the receiving queue are retrieved by the upper network layer, the sliding window size is increased. The retrieved packets, which are delivered to the upper applications if the receiving node is the sink node, are put into the sending queue of the receiving node - provided there are available spaces in the sending queue, or they are simply dropped if the sending queue is full of packets. The sliding window for the receiving queue in RAIT functions in the same way as those in traditional networks like the Internet. Figure 2 shows an example of a sliding window for a receiving queue with a size of 5. In general, a receiving queue with a size of 1 is used in a wireless sensor network because the sensor node normally has very limited memory size. As mentioned earlier, even if a packet is properly received in the receiving queue, the upper network layer can drop the packet in the case that the sending queue is full of previous packets. This situation can take place for many reasons, such as network congestion or link failure to an upper node. In such cases, general congestion control protocols are applied, which usually drop the overflow packets and employ a back-pressure technique to reduce the sending rate. As the back pressure propagates through the lower nodes in the routing tree the sending rate is reduced, and as a result, the congestion is eased gradually. However, it is very hard to evenly distribute the available bandwidth of a node to the lower nodes, so there can be imbalanced packet transmission among the lower nodes. Figure 2: Sliding window for receiving queue. Sliding window for receiving queue limits the number of packets that the sender can send at once. Moreover, dropped packets in congested nodes have to be retransmitted by the source nodes to guarantee end-to-end reliability, which requires the consumption of additional energy. Figure 3 illustrates packet dropping due to queue overflow in the sending nodes. The receiving queue in the receiving node has enough space for the sliding window to send an ACK packet for the received packet. The sender node therefore continues to send successive packets. Because there is no space in the sending queue in the receiving node, the retrieved packets from the receiving queue are dropped. Thus, while the dropped packets need to be retransmitted, this retransmission is not easily done because ACKed packets are emitted from the sending queue. If the dropped packets were generated from the sender node, it might retransmit the packets if they were stored elsewhere, such as in an upper layer buffer, which would require additional storage space. In the case that the sender node and source node are different and the sender node is just relaying the packets, the sender cannot retransmit the dropped packets because it has emitted the packets. The source node should be notified of the fact that some packets have been dropped. Some congestion control protocols or reliable transfer protocols use this scheme. However, the sink node has to inform the source node about the packets dropped and must wait until the packets retransmitted by the source arrive at the sink node. This requires storage space in the sink node to save the received packets, as well as a time delay. In RAIT, to prevent this effect, an additional sliding window is used for the sending queue in the receiving node, as shown in Figure 4. The sliding window for the sending queue is based on the available free space in the sending queue in the receiving node. The operation of the sliding window for the receiving queue is limited by the sliding window for the sending queue.