How should I convert Wifi signal strength from a Quality in percentage, usually 0% to 100% into an RSSI value, usually a negative dBm number (i.e. -96db
)?
The percentage represents the RSSI for a particular packet divided by the RSSI_Max value (multiplied by 100 to derive a percentage). Hence, a 50% signal strength with a Symbol card would convert to an RSSI of 16 (because their RSSI_Max = 31). Atheros, with RSSI_Max=60, would have RSSI=30 at 50% signal strength.
RSSI indicates the power level being received after any possible loss at the antenna and cable level. The higher the RSSI value, the stronger the signal. When measured in negative numbers, the number that is closer to zero usually means better signal strength.
dBm and RSSI are different units of measurement that both represent the same thing: signal strength. The difference is that RSSI is a relative index, while dBm is an absolute number representing power levels in mW (milliwatts).
Microsoft defines Wifi signal quality in their WLAN_ASSOCIATION_ATTRIBUTES structure as follows:
wlanSignalQuality:
A percentage value that represents the signal quality of the network. WLAN_SIGNAL_QUALITY is of type ULONG. This member contains a value between 0 and 100. A value of 0 implies an actual RSSI signal strength of -100 dbm. A value of 100 implies an actual RSSI signal strength of -50 dbm. You can calculate the RSSI signal strength value for wlanSignalQuality values between 1 and 99 using linear interpolation.
RSSI (or "Radio (Received) Signal Strength Indicator") are in units of 'dB' (decibel) or the similar 'dBm' (dB per milliwatt) (See dB vs. dBm) in which the smaller magnitude negative numbers have the highest signal strength, or quality.
Therefore, the conversion between quality
(percentage) and dBm
is as follows:
quality = 2 * (dBm + 100) where dBm: [-100 to -50] dBm = (quality / 2) - 100 where quality: [0 to 100]
Pseudo Code (with example clamping):
// dBm to Quality: if(dBm <= -100) quality = 0; else if(dBm >= -50) quality = 100; else quality = 2 * (dBm + 100); // Quality to dBm: if(quality <= 0) dBm = -100; else if(quality >= 100) dBm = -50; else dBm = (quality / 2) - 100;
Note:
Check the definition of Quality
that you are using for your calculations carefully. Also check the range of dB
(or dBm
). The limits may vary.
Examples:
Medium quality: 50% -> -75dBm = (50 / 2) - 100 Low quality: -96dBm -> 8% = 2 * (-96 + 100)
In JS I prefer doing something like:
Math.min(Math.max(2 * (x + 100), 0), 100)
My personal opinion is that it's more elegant way to write it, instead of using if
's.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With