set_quality(struct iw_quality *iq, u_int rssi, __u8 noise)
{
iq->qual = rssi;
/* NB: max is 94 because noise is hardcoded to 161 */
if (iq->qual > 94)
iq->qual = 94;
iq->noise = noise;
/* This noise is read from the ieee80211com which is updated by the ath layer,
* and the callback function of the ath layer points back to the function
* in the hal layer, in dBm, an thus being casted into __u8.
*/
iq->level = iq->noise + iq->qual;
iq->updated = 7;
}
Link Quality=79/94 Signal level=-16 dBm Noise level=-95 dBm
最关键的就是rssi和noise这两个东西是从哪里来的,先看看作者的注释
/*
* Units are in db above the noise floor. That means the
* rssi values reported in the tx/rx descriptors in the
* driver are the SNR expressed in db.
*
* If you assume that the noise floor is -95, which is an
* excellent assumption 99.5 % of the time, then you can
* derive the absolute signal level (i.e. -95 + rssi).
* There are some other slight factors to take into account
* depending on whether the rssi measurement is from 11b,
* , or . These differences are at most 2db and
* can be documented.
*
* NB: various calculations are based on the orinoco/wavelan
* drivers for compatibility
*/
看代码:
ieee80211_getrssi
case IEEE80211_M_STA: /* use stats from associated ap */
default:
TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next)
if (vap->iv_bss != NULL) {
rssi_samples++;
rssi_total += ic->ic_node_getrssi(vap->iv_bss);
}
break;
}
ic->ic_node_getrssi = ath_node_getrssi;
/*
* When only one frame is received there will be no state in
* avgrssi so fallback on the value recorded by the 802.11 layer.
*/
if (avgrssi != ATH_RSSI_DUMMY_MARKER)
rssi = HAL_EP_RND(avgrssi, HAL_RSSI_EP_MULTIPLIER);
else
rssi = ni->ni_rssi;
/* NB: theoretically we shouldn't need this, but be paranoid */
return rssi;
#undef HAL_EP_RND
}