The patch discussed in this article was incorporated in ipw2200-1.1.2.

The purpose of this note is to examine alternative models for reporting the wireless statistics for signal and noise level for ipw2200-1.1.1. Thanks to Jean Tourrilhes for suggesting that I look at exponential averaging.

Users typically encouner wireless statistics when using the wireless tools. For example,

iwconfig eth1 IEEE 802.11b ESSID:"mosswap" Mode:Managed Frequency:2.437 GHz Access Point: 00:01:24:F0:40:5A Bit Rate=11 Mb/s Tx-Power=20 dBm Retry limit:7 RTS thr:off Fragment thr:off Encryption key:****-****-****-****-****-****-** Security mode:open Power Management:off Link Quality=69/100 Signal level=-55 dBm Noise level=-82 dBm Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0 Tx excessive retries:0 Invalid misc:0 Missed beacon:1

If an access point is in range, the ipw2200 driver will process about 10 beacon packets per second producing unsigned 8 bit integer values for noise level. This happens even when the driver is not associated with an access point. On the other hand, when associated the driver collects one value for signal level about every three seconds. Sliding averages of the 8 most recent values for noise and signal level are maintained by ipw2200-1.1.1. These sliding averages are reported by iwconfig as 'Signal level' and 'Noise level.'

We propose to replace sliding averaging by exponential averaging. Both methods are used to smooth streams of data. Exponential averaging has better temporal characteristics, giving more weight to recent samples. Coding is much simpler and less memory and CPU are required.

Here is a code segment from my patched ipw2200.c which uses the model for exponential averaging presented in the RC filtering article discussed below.

#define DEPTH_RSSI 8 #define DEPTH_NOISE 16 static s16 exponential_average(s16 prev_avg, s16 val, u8 depth) { return ((depth-1)*prev_avg + val)/depth; }

The division by depth is more efficient if the depth is a power of 2.

The following article is a good a reference for exponential averaging. This article shows the connections between exponential averaging and RC low pass filtering.

http://www.prosig.com/signal-processing/DataSmoothing.html Data Smoothing: RC Filtering and Exponential Averaging

After some experimentation, I have chosen the DEPTH values

DEPTH_NOISE = 16 DEPTH_RSSI = 8

The financial management community also uses exponential averaging. The following article is a good reference.

http://www.asset-analysis.com/equities/tech_exmovaver.html Trend Indicator: Exponential Moving Average

In financial management, the model for the n-day exponential moving average (EMA) is

EMA(t) = ( (n-1)*EMA(t-1) + 2*P(t) )/(n+1)

where

n is the number of days used in the average EMA(t) is the exponential moving average on day t P(t) is the closing price on day t

Comparing these two ways to represent the exponential moving average, we see that

DEPTH = (n+1)/2

Comparing the two models for noise level, we have

16 = DEPTH_NOISE = (n+1)/2 => n = 31

That is, from the financial management perspective, we are averaging 31 noise level samples.

Comparing the two models for signal level, we have

8 = DEPTH_RSSI = (n+1)/2 => n = 15

That is, from the financial management perspective, we are averaging 15 signal level samples.

Here is some interesting noise level data collected in a low noise environment.

Type of Average Average Noise Sliding averaging -83 dBm Exponential averaging -86 dBm

The memory requirement and computation load is reduced when using exponential averaging. This reduced load seems to have a good effect on average noise.

The following patch to ipw2200.[ch] implements the above change of averaging method.

ipw2200-1.1.1 ipw2200_avg_rssi_noise.patch