Athero-CSI-tool-Python-RemoteReceive-Liveview-AmplitudeScaled icon indicating copy to clipboard operation
Athero-CSI-tool-Python-RemoteReceive-Liveview-AmplitudeScaled copied to clipboard

AGC in Atheros CSI Scaled

Open rafaelsilvag opened this issue 6 years ago • 7 comments

In Intel CSI Tool solution the scaled CSI is calculated removing AGC. This is a feature building in wireless card. How have you taken this information in your Scaled CSI Atheros calculation? What is the value "-95" in your implementation code for calculating the scaled CSI?

Regards,

rafaelsilvag avatar May 08 '18 13:05 rafaelsilvag

@rafaelsilvag Hi, the value "-95" comes from this paper: http://madwifi-project.org/attachment/wiki/UserDocs/RSSI/Converting_Signal_Strength.pdf?format=raw this paper was published in 2002. At that time the RSSI_max is 60 for Atheros and range is -95dBm to -35dBm. for the new Atheros 9K series, from the datasheet of the chips, we know that RSSI range from 0 to 127, 128 means invalid channel and RSSI is also in dB( https://www.openhacks.com/uploadsproductos/ar9331_datasheet.pdf ) with the Linux tool: iwconfig wlan0 we can get the total received power in dBm. and with Rohde & Schwarz Step Attenuator I test that even though the paper has been written for many years and the range of RSSI becomes wide, the relationship between RSSI and dBm still stay the same: this magic value "-95"

I have also found some record of my test: image

image

the power comes from iwconfig wlan0 is the total power for three antennas. related to RSSI not RSSI1, RSSI2 or RSSI3.

in another paper, we know that the power uncertainty is frequency band independent. i.e., the amplitude measured from different bands follow the same distribution. (http://pdcc.ntu.edu.sg/wands/yxxie/papers/Mobicom15_Splicer.pdf ) now we got the function for the scale of amplitude to dBm which you can find in the code.

shuspieler avatar May 08 '18 15:05 shuspieler

Hi @shuspieler

Thanks for your quick reply. Indeed, I've had some question because Intel CSI Tool that gets the total RSSI using a formula as follows:

ret = db(rssi_mag, 'pow') - 44 - csi_st.agc;

So, "csi_st.agc" is a value generated by Intel card and is combined with rssi_mag and the magical number "-44".

Now is clear to me how you generated the Scaled CSI and I thank you for your help. I 've made a fork in your project and I will try to contribute as soon as possible. We are expanding our research using this Atheros Card to work with many properties in an intelligent space.

Kind regards,

rafaelsilvag avatar May 08 '18 16:05 rafaelsilvag

Hi @rafaelsilvag you are welcome. It's my pleasure that I can help you. Best wishes

shuspieler avatar May 08 '18 16:05 shuspieler

Hi @rafaelsilvag, @shuspieler,

I understand both of you are probably moved on to other exciting projects by now, but I am wondering if you might be able to quickly address some further questions on the CSI amplitude values, or at least point one in the right direction. In my current project, we are hoping to use the CSI amplitude values in combination with the phase values (of which we thankfully have a stronger understanding) for our calculations. Did either of you discover further understanding of how to compensate for the AGC gain while scaling the amplitudes? Can the RSSI values be used as a corrective multiplier in this scaling process?

Thank you both, we appreciate all of your contributions to this forum to date.

ghost avatar Aug 26 '19 15:08 ghost

Hello @shaneearley10 , did you solve the problem with the agc gain? I am also struggling with it, could you help me? my email is [email protected] Many thanks

fatihoezdemir avatar Jun 25 '20 21:06 fatihoezdemir

Hi @rafaelsilvag, @shuspieler, I have a question about calculating 'scaled CSI'

I also work on CSI. In 'get_scaled_csi.m' line 40, 37,34: ret = csi * sqrt(scale / total_noise_pwr); total_noise_pwr = thermal_noise_pwr + quant_error_pwr; quant_error_pwr = scale * (csi_st.Nrx * csi_st.Ntx);

It seems that 'ret' finally only depends on 'csi_st.Nrx * csi_st.Ntx' since 'thermal_noise_pwr =0' and numerator and denominator both have 'scale' and thus 'ret' does not refer to 'scale'?

get_scaled_csi.m

%GET_SCALED_CSI Converts a CSI struct to a channel matrix H.
%
% (c) 2008-2011 Daniel Halperin <[email protected]>
%
function ret = get_scaled_csi(csi_st)
    % Pull out CSI
    csi = csi_st.csi;

    % Calculate the scale factor between normalized CSI and RSSI (mW)
    csi_sq = csi .* conj(csi);
    csi_pwr = sum(csi_sq(:));
    rssi_pwr = dbinv(get_total_rss(csi_st));
    %   Scale CSI -> Signal power : rssi_pwr / (mean of csi_pwr)
    scale = rssi_pwr / (csi_pwr / 30);

    % Thermal noise might be undefined if the trace was
    % captured in monitor mode.
    % ... If so, set it to -92
    if (csi_st.noise == -127)
        noise_db = -92;
    else
        noise_db = csi_st.noise;
    end
    thermal_noise_pwr = 0;%dbinv(noise_db);
    
    % Quantization error: the coefficients in the matrices are
    % 8-bit signed numbers, max 127/-128 to min 0/1. Given that Intel
    % only uses a 6-bit ADC, I expect every entry to be off by about
    % +/- 1 (total across real & complex parts) per entry.
    %
    % The total power is then 1^2 = 1 per entry, and there are
    % Nrx*Ntx entries per carrier. We only want one carrier's worth of
    % error, since we only computed one carrier's worth of signal above.
    quant_error_pwr = scale * (csi_st.Nrx * csi_st.Ntx);

    % Total noise and error power
    total_noise_pwr = thermal_noise_pwr + quant_error_pwr;

    % Ret now has units of sqrt(SNR) just like H in textbooks
    ret = csi * sqrt(scale / total_noise_pwr);
    if csi_st.Ntx == 2
        ret = ret * sqrt(2);
    elseif csi_st.Ntx == 3
        % Note: this should be sqrt(3)~ 4.77 dB. But, 4.5 dB is how
        % Intel (and some other chip makers) approximate a factor of 3
        %
        % You may need to change this if your card does the right thing.
        ret = ret * sqrt(dbinv(4.5));
    end
end

evileleven avatar Mar 14 '24 04:03 evileleven

It seems that:Pa(dBm) = RSSIa − AGC − C (paper: RSSI–CSI Measurement and Variation Mitigation With Commodity Wi-Fi Device) In this way, what should be the value of 'C'?

AGC+C = 95?

evileleven avatar Mar 21 '24 10:03 evileleven