wifi熱點服務hostapd啟動需要配置hostad.conf文件,其中有一個參數channel是用來配置信道的,信道的可選參數如下:
# channel 1-14 is 2.4 GHz ; channel 36, 40, 44, 46, 48, 52, 56, 60,
# 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149,
# 153, 157, 161 is 5GHz
# The channels that are available for use in a particular country differ
# according to the regulations of that country.
如果只是要配置正確在可選范圍內隨便填一個就可以了,但是如果需要選出一個當前環境下最優的一個信道,就需要動動手指了。
我們需要戒指iwlist工具來掃描一下,然后就可以找到最優信道了
ifconfig wlan0 up iwlist wlan0 scan iwlist wlan0 scan iwlist wlan0 scan
掃面了三次,現在我們可以去看下最優信道是哪個了,我的網卡是rtl8188eu,通過以下指令獲取
[root@t3_p3 /]# cat /proc/net/rtl8188eu/wlan0/best_channel
The rx cnt of channel 1 =8
The rx cnt of channel 2 = 11
The rx cnt of channel 3 = 12
The rx cnt of channel 4 = 15
The rx cnt of channel 5 = 20
The rx cnt of channel 6 = 31
The rx cnt of channel 7 = 22
The rx cnt of channel 8 = 17
The rx cnt of channel 9 = 13
The rx cnt of channel 10 = 12
The rx cnt of channel 11 = 14
The rx cnt of channel 12 = 9
The rx cnt of channel 13 = 7
The rx cnt of channel 14 = 0
best_channel_5G = 36
best_channel_24G = 1
[root@t3_p3 /]#
如果沒有走scan掃描直接去cat 那么channel后面接收到的數據包全都是0
The result of “cat /proc/net/rtl…/wlan0/best_channel” has two parts. The first part is received packet count at all supported channels during site survey. Developers can use these statics to decide your own best channel. The second part is the simple estimated best channels for 5G and 2.4G band for reference only. HT40+ rule is used to estimate the best channel when the primary channel is at 1, 6, 36, 44, etc., and the primary channel with minimum received packet count is selected
我們要找的是計數包最小的那個通道(14通道除外),類似於干擾最小的信道。
wifi熱點啟動后我們可以在手機上安裝wifi魔盒一類的wifi查看器,查看當前環境下的各個熱點、信道、信號質量等信息。