On Thu, Dec 31, 2020 at 02:28:35PM +0000, Björn Gohla wrote:
> 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?
Rate/MCS + channel width + some other parameters map to a Tx bitrate:
https://en.wikipedia.org/wiki/IEEE_802.11n-2009#Data_rates
This Tx bitrate will vary on a per-frame basis, though. And actual user data
throughput is always below this, due to protocol overhead, re-transmissions,
interference, other traffic on the same channel, and so on.
> The interface is a "Realtek Wireless N Nano USB Adapter" in case that is
> relevant.
OpenBSD realtek wifi drivers only support 11g mode at present.
So on such hardware the kernel and ifconfig never report "MCS23".
MCS are only reported for 11n/ac modes.
In 11g mode the per-frame Tx rate is displayed by ifconfig in Mbit/s.
However, some realtek devices (like the 8192CU) perform Tx rate-adjustment
in firmware and do not even expose the chosen Tx data rate to the driver.
In that case ifconfig always displays 54M which is usually incorrect.
What problem are you trying to solve?
No comments:
Post a Comment