(一百零四)探讨WiFi分析仪如何获取信道的?

版权声明:本文为博主原创文章,未经授权禁止转载,O(∩_∩)O谢谢 https://blog.csdn.net/sinat_20059415/article/details/83927714

前言:下载了WiFi分析仪,发现WiFi分析仪会显示当前扫描AP的信道,但是信道是没有公开接口的,那WiFi分析仪如何获取的呢?

参考:

1.https://blog.csdn.net/strugglelg/article/details/38927633(WiFi基本知识)

2.https://blog.csdn.net/strugglelg/article/details/38893287(2.4G wifi 的频道/信道 20M 40M的概念,区别)

1.WiFi分析仪

WiFi分析仪扫描结果如上,可以看到扫描到的消息是ap的ssid、BSSID、信道、当前频率、加密方式,当前连接AP、ip地址和路由器厂商,我用的是TP-LINK 2.4G+5G的路由器。

2.ScanResult

ScanResult是代表扫描结果的,当时其声明的成员变量并没有带有channel,那WiFi分析仪是如何获取信道的呢?

3.获取信道方法

3.1 频谱划分

     1)IEEE 802.11b/g标准工作在2.4G频段,频率范围为2.400—2.4835GHz,共83.5M带宽

     2)划分为14个子信道

     3)每个子信道宽度为22MHz
     4)相邻信道的中心频点间隔5MHz 
     5)相邻的多个信道存在频率重叠(如1信道与2、3、4、5信道有频率重叠)
     6)整个频段内只有3个(1、6、11)互不干扰信道

3.2 2.4GHz中国信道划分

3.3 计算信道

举个例子,比如我用的2.4G的AP,虽然比较慢,我都用的5G的

ap的频率为2462MHz,而2462MHz是信道11的中心频率,WiFi分析仪则认为该AP是处于信道11上,那后面11+7是什么意思呢?

这是40MHz 信道宽度的AP。

40MHZ 实际上是用了两个频道, 20MHZ 实际上是用了1个频道 。

每个子信道宽度为22MHz,然后40MHZ的宽度相当于将左边临近的一个不重叠的信道包含进来,加起来恰好是40MHz左右,11信道左边不重叠的是7信道,这也就是信道11+7表示的含义。

4. ScanResult PS

信道宽度


   /**
    * AP Channel bandwidth is 20 MHZ
    */
    public static final int CHANNEL_WIDTH_20MHZ = 0;
   /**
    * AP Channel bandwidth is 40 MHZ
    */
    public static final int CHANNEL_WIDTH_40MHZ = 1;
   /**
    * AP Channel bandwidth is 80 MHZ
    */
    public static final int CHANNEL_WIDTH_80MHZ = 2;
   /**
    * AP Channel bandwidth is 160 MHZ
    */
    public static final int CHANNEL_WIDTH_160MHZ = 3;
   /**
    * AP Channel bandwidth is 160 MHZ, but 80MHZ + 80MHZ
    */
    public static final int CHANNEL_WIDTH_80MHZ_PLUS_MHZ = 4;
   /**
    * AP Channel bandwidth; one of {@link #CHANNEL_WIDTH_20MHZ}, {@link #CHANNEL_WIDTH_40MHZ},
    * {@link #CHANNEL_WIDTH_80MHZ}, {@link #CHANNEL_WIDTH_160MHZ}
    * or {@link #CHANNEL_WIDTH_80MHZ_PLUS_MHZ}.
    */
    public int channelWidth;

中心频率

    /**
     * Not used if the AP bandwidth is 20 MHz
     * If the AP use 40, 80 or 160 MHz, this is the center frequency (in MHz)
     * if the AP use 80 + 80 MHz, this is the center frequency of the first segment (in MHz)
     */
    public int centerFreq0;

    /**
     * Only used if the AP bandwidth is 80 + 80 MHz
     * if the AP use 80 + 80 MHz, this is the center frequency of the second segment (in MHz)
     */
    public int centerFreq1;

ssid

    /**
     * The network name.
     */
    public String SSID;

    /**
     * Ascii encoded SSID. This will replace SSID when we deprecate it. @hide
     */
    public WifiSsid wifiSsid;

    /**
     * The address of the access point.
     */
    public String BSSID;

    /**
     * The HESSID from the beacon.
     * @hide
     */
    public long hessid;

信号强度

    /**
     * The detected signal level in dBm, also known as the RSSI.
     *
     * <p>Use {@link android.net.wifi.WifiManager#calculateSignalLevel} to convert this number into
     * an absolute signal level which can be displayed to a user.
     */
    public int level;

5.总结

信道总体来讲是没有直接接口获取的,但可以通过AP的频率和信道宽度算出来,注意40MHZ信道宽度的AP占据了两个信道。

猜你喜欢

转载自blog.csdn.net/sinat_20059415/article/details/83927714
今日推荐