# Implementation of a Fast Link Rate Adaptation Algorithm for WLAN Systems
## 3 The Link Adaptation Firmware
### Function Offset_Update  
The inputs to the offset_update function are the mcsin integer data type (the MCS index applied to the previous packet), the ack integer data type (the ACK concerning the previous packet), and the snr_offset pointer to float data type (the SNR offset value per MCS). The function offset_update, as explained in Section 3.1, references the ACK of the previous packet and accordingly renews the SNR offset. If the previous transmission has succeeded, the SNR offset is multiplied by the ACK_OFFSET value (A0 state in Figure 10), whereas if the previous transmission has failed, the offset is multiplied by the NACK_OFFSET value. In state A0, if two NACKs occur in sequence, NACK_OFFSET is multiplied (N1 state). The update step of the SNR offset is not constant but varies according to a given condition. More specifically, if the channel SNR compensation by the SNR offset is not enough, update steps with a large step up or a large step down are made use of to rapidly compensate for the channel SNR. In this case the SNR offset update step is set to 0.015 dB in case of an ACK and 0.15 dB in case of a NACK. After it is decided that the channel SNR mismatch compensation is nearly attained, update steps with a small step up and a small step down are exploited to finely tune the channel SNR mismatch, in which case the SNR offset update step is set to 0.005 dB with an ACK and 0.05 dB with a NACK. How the values of the SNR offset update step are determined is explained as follows. If the update step is chosen too small, the adaptation is unable to keep track of the channel variation or unable to compensate for the error in the MMI-to-PER mapping table whereas if chosen too large, much deviation from the mapping table will arise. Generally, the update step may well be chosen smaller in case of slow fading and larger in case of fast fading, which is demonstrated in Table 2 in Section 6 later on. In this paper, the SNR offset values for ACK and NACK are determined empirically to achieve the balance mentioned above, from a multitude of wireless tests. If the SNR offset value does not oscillate around a specific value but continually increases or decreases, it is decided that the channel SNR mismatch compensation is not sufficient. On the contrary, the channel SNR mismatch compensation being almost reached is judged from the SNR offset value fluctuating around a specific value. \[M_{k+1}=0.95\cdot M_{k}+0.05\cdot Offset_{k} \tag{9}\]  
\[D_{k+1}=0.9\cdot D_{k}+0.1\cdot(Offset_{k}-M_{k}) \tag{10}\]  
In Equations (9) and (10), \(Offset_{k}\) is the SNR offset up to the \(k\)-th packet, \(M_{k}\) is the mean SNR offset up to the \(k\)-th packet, and \(D_{k}\) is the mean variation (or deviation) of the SNR offset up to the \(k\)-th packet. Equations (9) and (10) represent IIR filters to take on averages, which are to filter out the SNR variations caused by AWGN observed in wireless tests. As is well-known, the sum of the coefficients is set to be unity, e.g., 0.95 + 0.05 = 1 and 0.9 + 0.1 = 1, where each of the coefficients, 0.05 and 0.1, that is attached to the new sample, is the forgetting factor of the IIR filter, which decides the magnitude of the average window of the filter. For instance, if the forgetting factor is 0.05 (0.1), the magnitude of the average window is 20 (10) samples wide. In this paper, the forgetting factors are determined from AWGN and Doppler identified in wireless tests. \[0.02\cdot M_{k}>D_{k} \tag{11}\]  
Since \(M_{k}\) and \(D_{k}\) denote the average SNR offset and the average variation of the SNR offset, respectively, inequality Equation (11) is the condition that discerns whether the channel SNR mismatch compensation is enough or not. If the value that relates \(M_{k}\) and \(D_{k}\) in Equation (11), 0.02 in our case, is set too large, then the update step will be diminished too early before the SNR offset value oscillates around a specific value.