wiki:Internal/WinlabMadwifi -> Introduction to Rate Control = Rate Control = General Information could be found in this [http://madwifi.org/wiki/UserDocs/RateControl link]. Rate control, or rate adaptation, is a technique to adapt PHY channel rate in sender node. With the help of either some explicit feedback from recever (ACK frames) or implicit information (RSSI), the sender infers channel quality and choose a proper modulation scheme for next outgoing packet to maintain acceptable BER/PER/Throughput performance. Files involved for rate control: * ath/if_ath.c * ath/if_athrate.h * ath_rate/amrr/amrr.h * ath_rate/amrr/amrr.c * ath_rate/onoe/onoe.h * ath_rate/onoe/onoe.c * ath_rate/sample/sample.h * ath_rate/sample/sample.c == Main interfaces in if_ath.c == === When the rate is determined? === when a packet is xmitted, a rate has to be determined associate with this packet. This is done in the ''ath_tx_start(struct net_device *dev, struct ieee80211_node *ni, struct ath_buf *bf, struct sk_buff *skb)'' function. A call to '''ath_rate_findrate''' will fill the pointer to ''txrate'' and this rate will be passed into tx-descriptor. {{{ if (ic->ic_fixed_rate == -1) { / * Data frames; consult the rate control module. */ ath_rate_findrate(sc, an, shortPreamble, pktlen, &rix, &try0, &txrate); } else { rix = ic->ic_fixed_rate; try0 = ATH_TXMAXTRY; //XXX: should be configuralbe if (shortPreamble) txrate = rt->info[rix].shortPreamble; else txrate = rt->info[rix].rateCode; } }}} === When statistics are collected? === After the packet is transmitted, function ''ath_tx_processq(struct ath_softc *sc, struct ath_txq *txq)'' is executed. In this function, ''' ath_rate_tx_complete''' will be called. {{{ sr = ds->ds_txstat.ts_shortretry; lr = ds->ds_txstat.ts_longretry; sc->sc_stats.ast_tx_shortretry += sr; sc->sc_stats.ast_tx_longretry += lr; /* * Hand the descriptor to the rate control algorithm. */ if ((ds->ds_txstat.ts_status & HAL_TXERR_FILT) == 0 && (bf->bf_flags & HAL_TXDESC_NOACK) == 0) ath_rate_tx_complete(sc, an, ds); }}} ''sc'' contains updated statistics and will be read by rate control module. == Rate-control modules == == Function: ath_rate_findrate == This function takes following parameters: * '''struct ath_softc * sc''' :local priv in driver * ''' struct ath_node * an''' : Destination Node * int shortPreamble, * '''size_t frameLen''' : used by SampleRate algorithm to calculate throughput for a certain packet length bin. * '''u_int8_t''' *rix, * '''int *try0''' : return to show how many attempts should be used for this txrate. * '''u_int8_t''' *txrate : return the transmit rate.