| 10 |   | This algorithm conducts a per-MAC destination rate control. For each different destination, link statistics are stored separately. | 
          
          
            |   | 11 | Description of functions in sample.c: | 
          
          
            |   | 12 |  | 
          
          
            |   | 13 | {{{ | 
          
          
            |   | 14 |    I. static __inline int best_rate_ndx(struct sample_node *sn, int size_bin, int require_acked_before) | 
          
          
            |   | 15 | }}} | 
          
          
            |   | 16 |  | 
          
          
            |   | 17 | The objective of this function is to return the bit-rate with the lowest avg. pkt. tx. time. | 
          
          
            |   | 18 | {{{ | 
          
          
            |   | 19 |    Process information starting from the lowest rate: | 
          
          
            |   | 20 |    1. if ((avg. pkt. tx. time for this pkt. size and bit-rate <= 0) or  | 
          
          
            |   | 21 |           ((packets have not been acked for this pkt. size and bit-rate) and  | 
          
          
            |   | 22 |           (multi-rate retry is disabled))) | 
          
          
            |   | 23 |          process next higher bit-rate; | 
          
          
            |   | 24 |    2. if (processing 9Mbps) | 
          
          
            |   | 25 |          process next higher bit-rate; // 9Mbps is never better than 12Mbps | 
          
          
            |   | 26 |    3. if (successive failures at this rate > 3) | 
          
          
            |   | 27 |          process next higher bit-rate; | 
          
          
            |   | 28 |    4. if (avg. pkt. tx. time for this rate is lowest so far) | 
          
          
            |   | 29 |          set best_rate_index to that of current rate; | 
          
          
            |   | 30 |  | 
          
          
            |   | 31 |    if (best rate index found) | 
          
          
            |   | 32 |       return best_rate_index;      | 
          
          
            |   | 33 |    else | 
          
          
            |   | 34 |       return -1; | 
          
          
            |   | 35 | }}} | 
          
          
            |   | 36 |  | 
          
          
            |   | 37 | {{{ | 
          
          
            |   | 38 |    II. static __inline int pick_sample_ndx(struct sample_node *sn, int size_bin) | 
          
          
            |   | 39 | }}} | 
          
          
            |   | 40 |  | 
          
          
            |   | 41 | The objective of this function is to return the index of a "suitable" bit-rate that can be sampled. | 
          
          
            |   | 42 | {{{ | 
          
          
            |   | 43 |    1. if (no packets have been sent successfully at any of the higher bit-rates) | 
          
          
            |   | 44 |          return (index of lowest bit-rate);  | 
          
          
            |   | 45 |    2. current_tx_time = avg. tx. time for the bit-rate at which the card was operating in the previous interval; | 
          
          
            |   | 46 |    3. Process information starting from the index of the lowest rate (for (i = 0); i < max_rate_index; i++)): | 
          
          
            |   | 47 |       1. Choose 1 + the index of the last rate that was sampled + i; | 
          
          
            |   | 48 |       2. if (i == current_rate_index) | 
          
          
            |   | 49 |              proceed to next higher bit-rate; | 
          
          
            |   | 50 |       3. if (perfect_tx_time(rate(i)) > avg. tx. time (current rate)) | 
          
          
            |   | 51 |              proceed to next higher bit-rate; | 
          
          
            |   | 52 |       4. if ((last tx. at rate(i) was less than 10 seconds ago) and  | 
          
          
            |   | 53 |              (successive failures at rate(i) > 3))  | 
          
          
            |   | 54 |              proceed to next higher bit-rate; | 
          
          
            |   | 55 |       5. if ((rate(i) > 11Mbps) and (rate(i) > current rate + 2)) | 
          
          
            |   | 56 |              proceed to next higher bit-rate; | 
          
          
            |   | 57 |       6. if (rate(i) == 9Mbps) | 
          
          
            |   | 58 |              process next higher bit-rate; // 9Mbps is never better than 12Mbps | 
          
          
            |   | 59 |       7. if ((current rate == 11Mbps) and (rate(i) > 12Mbps)) | 
          
          
            |   | 60 |              proceed to next higher bit-rate; | 
          
          
            |   | 61 |       8. return i; | 
          
          
            |   | 62 | }}} |