Thursday, December 31, 2020

Getting wifi bitrate

Hi all,

I have a small question: I want to get the current rate of actually
transmitted (and received) bits for my wifi adaptor. I thought this
fragment from ifconfig does what I want
(https://github.com/openbsd/src/blob/3a44e88910781e836bd51a8b6b068379abc67a1b/sbin/ifconfig/ifconfig.c#L2783):

if ((nr->nr_flags & (IEEE80211_NODEREQ_AP)) == 0) {
if (nr->nr_flags & IEEE80211_NODEREQ_VHT) {
printf("VHT-MCS%d/%dSS", nr->nr_txmcs, nr->nr_vht_ss);
} else if (nr->nr_flags & IEEE80211_NODEREQ_HT) {
printf("HT-MCS%d ", nr->nr_txmcs);
} else if (nr->nr_nrates) {
printf("%uM ",
(nr->nr_rates[nr->nr_txrate] & IEEE80211_RATE_VAL)
/ 2);
}
} else if (nr->nr_max_rxrate) {
printf("%uM HT ", nr->nr_max_rxrate);
} else if (nr->nr_rxmcs[0] != 0) {
for (i = IEEE80211_HT_NUM_MCS - 1;
i >= 0; i--) {
if (nr->nr_rxmcs[i / 8] & (1 << (i / 10)))
break;
}
printf("HT-MCS%d ", i);
} else if (nr->nr_nrates) {
printf("%uM ",
(nr->nr_rates[nr->nr_nrates - 1] &
IEEE80211_RATE_VAL) / 2);
}

But when I paste that into my application code and run it I get
"HT-MCS23". My best understanding is that this refers to some definition
of modulation coding schemes, i.e., not the bitrate I'm looking for.

So how do I get the it? Am I looking in the wrong place, or does the
driver just not expose this information?

The interface is a "Realtek Wireless N Nano USB Adapter" in case that is
relevant.

Cheers and a happy new year,
Björn

No comments:

Post a Comment