momo zone

调核人的blog

wifi region setup

深晦wifi设置之道的人都知道channel 的最佳设置,之前我有谈过这个问题,就是1,6,11这个几个channel是独立的,受到的干扰比较少。其实呢 还有12 (Europe and Japan), 13 (Europe and Japan), and 14 (Japan only)频道,实际使用的情况是13频道的效果更好(14频道没有用过)

不过也不是所有的卡都有这么宽的频道,不幸买到US限定的就只有1-11频道。可恶,我手里就有这样一块烂卡。

搞定这个问题有两个途径:

1. 对cfg80211 内核模块设定参数:

ieee80211_regdom=JP

2. 使用用户空间的CRDA 工具:

export COUNTRY=JP;crda

已尝试,确认不能用,返回:Failed to set regulatory domain: -22 ,也许是调用crda的时机不对。

*****************************************************

不过我试过好像加内核模块参数对intel 4965/5X00 不起作用,而对realtek 8187是管用的:

比如我的8187 默认的region就有14个频道:

# iw reg get
country 00:
        (2402 - 2472 @ 40), (3, 20)
        (2457 - 2482 @ 20), (3, 20), PASSIVE-SCAN, NO-IBSS
        (2474 - 2494 @ 20), (3, 20), NO-OFDM, PASSIVE-SCAN, NO-IBSS
        (5170 - 5250 @ 40), (3, 20), PASSIVE-SCAN, NO-IBSS
        (5735 - 5835 @ 40), (3, 20), PASSIVE-SCAN, NO-IBSS
# iwlist wlan0 f
wlan0     14 channels in total; available frequencies :
          Channel 01 : 2.412 GHz
          Channel 02 : 2.417 GHz
          Channel 03 : 2.422 GHz
          Channel 04 : 2.427 GHz
          Channel 05 : 2.432 GHz
          Channel 06 : 2.437 GHz
          Channel 07 : 2.442 GHz
          Channel 08 : 2.447 GHz
          Channel 09 : 2.452 GHz
          Channel 10 : 2.457 GHz
          Channel 11 : 2.462 GHz
          Channel 12 : 2.467 GHz Channel 13 : 2.472 GHz Channel 14 : 2.484 GHz

假设这里要限定成US,即 1-11 channel ,可以这样做:

# modprobe -r iwlagn iwlcore rtl8187 mac80211 cfg80211
# modprobe -v cfg80211 ieee80211_regdom=US
insmod /lib/modules/2.6.38.4-1-desktop/kernel/net/rfkill/rfkill.ko
insmod /lib/modules/2.6.38.4-1-desktop/kernel/net/wireless/cfg80211.ko ieee80211_regdom=US
# iw reg get
country US:
        (2402 - 2472 @ 40), (3, 27)
        (5170 - 5250 @ 40), (3, 17)
        (5250 - 5330 @ 40), (3, 20), DFS
        (5490 - 5600 @ 40), (3, 20), DFS
        (5650 - 5710 @ 40), (3, 20), DFS
        (5735 - 5835 @ 40), (3, 30)
# modprobe rtl8187
# iwlist wlan0 f
wlan0     11 channels in total; available frequencies :
          Channel 01 : 2.412 GHz
          Channel 02 : 2.417 GHz
          Channel 03 : 2.422 GHz
          Channel 04 : 2.427 GHz
          Channel 05 : 2.432 GHz
          Channel 06 : 2.437 GHz
          Channel 07 : 2.442 GHz
          Channel 08 : 2.447 GHz
          Channel 09 : 2.452 GHz
          Channel 10 : 2.457 GHz
          Channel 11 : 2.462 GHz

内核参数的确起作用了

而且通过sys也可以查看region:

cat /sys/module/cfg80211/parameters/ieee80211_regdom

kernel log的讯息:

[26950.201850] cfg80211: Calling CRDA for country: US
[26950.205166] cfg80211: Regulatory domain changed to country: US
[26950.205168] cfg80211:     (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp)
[26950.205171] cfg80211:     (2402000 KHz - 2472000 KHz @ 40000 KHz), (300 mBi, 2700 mBm)
[26950.205173] cfg80211:     (5170000 KHz - 5250000 KHz @ 40000 KHz), (300 mBi, 1700 mBm)
[26950.205175] cfg80211:     (5250000 KHz - 5330000 KHz @ 40000 KHz), (300 mBi, 2000 mBm)
[26950.205177] cfg80211:     (5490000 KHz - 5600000 KHz @ 40000 KHz), (300 mBi, 2000 mBm)
[26950.205179] cfg80211:     (5650000 KHz - 5710000 KHz @ 40000 KHz), (300 mBi, 2000 mBm)
[26950.205181] cfg80211:     (5735000 KHz - 5835000 KHz @ 40000 KHz), (300 mBi, 3000 mBm)

可以看到挂载内核加参数实际也调用了CRDA ??没错,就在执行modprobe之后,cfg80211实际只是把参数传给crda,然后去设置。如果手动操作也ok:
iw reg set JP
上述工具命令在挂载网卡驱动模块后将失效哦

如果要在开机设置cfg80211的参数可以这样:

echo options cfg80211 ieee80211_regdom=US >>/etc/modprobe.d/XX-option

关于CRDA和rgdb 的信息可以查看这个链接http://wireless.kernel.org/en/developers/Regulatory/#The_regulatory_database

Advertisements

发表评论

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Google+ photo

You are commenting using your Google+ account. Log Out / 更改 )

Connecting to %s

%d 博主赞过: