Stefan Sperling <[email protected]> writes:

> ifconfig scan displays RSSI (received signal strength indicator) values.
>
> If the driver sets ic->ic_max_rssi the value is displayed as a percentage
> of ic_max_rssi. Otherwise ifconfig displays the value as dBm.
>
> The problem in the dBm case is that many drivers end up reporting a positive
> value. The range for 802.11 networks is -10dBm to -100dBm (wikipedia has a
> table at https://en.wikipedia.org/wiki/DBm).
>
> In January 2016 sthen@ fixed this problem for some drivers by converting
> from an unsigned value to a signed value at the ioctl boundary.
> This approach works for drivers which report values in the (unsigned) range
> 128 - 255. But there are some drivers which report RSSI values in the 20 to
> 100 range. These are fixed by the diff below.

Makes sense, ok jca@.  Nit below.

> A few drivers report bogus values altogether, and some always report the
> same value. I'm not going to bother fixing those.
>
> Index: ieee80211_ioctl.c
> ===================================================================
> RCS file: /cvs/src/sys/net80211/ieee80211_ioctl.c,v
> retrieving revision 1.42
> diff -u -p -r1.42 ieee80211_ioctl.c
> --- ieee80211_ioctl.c 15 Aug 2016 22:14:19 -0000      1.42
> +++ ieee80211_ioctl.c 30 Aug 2016 15:36:50 -0000
> @@ -60,6 +60,8 @@ void
>  ieee80211_node2req(struct ieee80211com *ic, const struct ieee80211_node *ni,
>      struct ieee80211_nodereq *nr)
>  {
> +     uint8_t rssi;
> +
>       /* Node address and name information */
>       IEEE80211_ADDR_COPY(nr->nr_macaddr, ni->ni_macaddr);
>       IEEE80211_ADDR_COPY(nr->nr_bssid, ni->ni_bssid);
> @@ -73,7 +75,19 @@ ieee80211_node2req(struct ieee80211com *
>       bcopy(ni->ni_rates.rs_rates, nr->nr_rates, IEEE80211_RATE_MAXSIZE);
>  
>       /* Node status information */
> -     nr->nr_rssi = (*ic->ic_node_getrssi)(ic, ni);
> +     rssi = (*ic->ic_node_getrssi)(ic, ni);
> +     if (ic->ic_max_rssi) {
> +             /* Driver reports RSSI relative to ic_max_rssi. */
> +             nr->nr_rssi = rssi;
> +     } else {
> +             /* 

trailing space

> +              * Driver reports RSSI value in dBm.
> +              * Convert from unsigned to signed.
> +              * Some drivers report a negative value, some don't.
> +              * Reasonable range is -20dBm to -80dBm.
> +              */
> +             nr->nr_rssi = (rssi < 128) ? -rssi : rssi;
> +     }
>       nr->nr_max_rssi = ic->ic_max_rssi;
>       bcopy(ni->ni_tstamp, nr->nr_tstamp, sizeof(nr->nr_tstamp));
>       nr->nr_intval = ni->ni_intval;
>

-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE

  • RSSI values Stefan Sperling
    • Re: RSSI values Jeremie Courreges-Anglas

Reply via email to