Chinaunix首页 | 论坛 | 博客
  • 博客访问: 466901
  • 博文数量: 100
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 955
  • 用 户 组: 普通用户
  • 注册时间: 2014-11-21 09:30
文章分类

全部博文(100)

文章存档

2017年(1)

2016年(16)

2015年(83)

我的朋友

分类: 嵌入式

2015-08-18 01:35:20

WIFI是通过认证允许获得许可的设备连接到wifi网络。
以手机上WIFI热点为例,有4种常用的"认证/加密方式":
a. OPEN(可不加密,也可使用WEP加密)
b. WEP(WEP加密)
c. WPA(TKIP 加密),有2种:
   802.1x/TKIP,兼容WEP加密
   PSK/TKIP,兼容WEP加密
d. WPA2(AES 加密),有2种:
    802.1x/CCMP(AES加密),兼容TKIP、WEP
    PSK/CCMP(AES加密),兼容TKIP、WEP

其中OPEN和WEP安全性很差,容易被破解

要支持wifi,
内核需配置以下2个模块:
-> Networking suppor
  -> Wireless 
    <*>   cfg80211 - wireless configuration API
    <*>   Generic IEEE 802.11 Networking Stack (mac80211)

WIFI设备的工作分为STA模式和AP模式,STA就是类似于手机,AP就是热点。
调试wifi(STA功能)可以使用以下3个工具:
iw(iwconfig 的改进版),wpa_supplicant,dhcpd
iw和wpa_supplicant用于配置、控制wifi网卡(默认为wlan0),其中iw支持open和wep认证方式,wpa_supplicant支持以上4种认证方式,可见,完全可以抛弃iw,直接使用wpa_supplicant即可。
dhcpd用于从wifi热点自动获取IP地址和DNS。

实际上,只使用wpa_supplicant也可以简单调试wifi。

@百问科技-st 请问第2期 第2课第1.1_15节中,韦老师在ping  q.com 时,怎么知道此时是用wifi去访问网络,而不是有线网络(dm9000)呢?如何控制系统,即使在wifi已连接时,仍然使用dm9000去访问外网。
测试:
要让wifi能工作,首先要进入监听模式:

#iwconfig wlan0 mode ad-hoc


iwconfig wlan0 ap GKDS_RRTT

nameserver 210.21.4.130
nameserver 221.5.88.88

[root@EmbedSky /etc]# cat /etc/wpa_supplicant.conf
ctrl_interface=/var/run/wpa_supplicant
ctrl_interface_group=0
ap_scan=1
network={
        ssid="GKDS_RRTT"
        psk="1234568899"
        scan_ssid=1
        proto=WPA
        key_mgmt=WPA-EAP WPA-PSK IEEE8021X NONE
        pairwise=TKIP CCMP
        group=CCMP TKIP WEP104 WEP40
}

root@EmbedSky wireless]# tqnetset -qws &
[root@EmbedSky wireless]# Could not read calibration: "/etc/pointercal"
0x1300 = 00064300
Try to bring net interface up ...
0x1300 = 00064300
wpa_supplicant -B -iwlan0 -c/etc/wpa_supplicant.conf
1
wpa_cli -iwlan0 add_network
OK
wpa_cli -iwlan0 enable_network 0
sh: 1: unknown operand
ifconfig wlan0 192.168.1.54 netmask 255.255.255.0 up
route add default gw 192.168.1.2
Done
m_strName->wlan0
读取到的数据:wlan0     Scan completed :          Cell 01 - Address: FC:D7:33:4A:DD:B8                    Protocol:802.11b/g/n                        i
读取到的数据: Cell 07 - Address: D8:15:0D:64:1D:B8                    Protocol:802.11b/g/n                    ESSID:"GKDS_RRTT"                      0
Try to bring net interface up ...
0x1300 = 00064300
ctrl_iface exists and seems to be in use - cannot override it
Delete '/var/run/wpa_supplicant/wlan0' manually if it is not used anymore
Failed to initialize control interface '/var/run/wpa_supplicant'.
You may have another wpa_supplicant process already running or the file was
left by an unclean termination of wpa_supplicant in which case you will need
to manually remove this file before starting wpa_supplicant again.

wpa_supplicant -B -iwlan0 -c/etc/wpa_supplicant.conf
2
wpa_cli -iwlan0 add_network
OK
wpa_cli -iwlan0 enable_network 0
sh: 1: unknown operand
0x1300 = 00064300
ifconfig wlan0 192.168.1.54 netmask 255.255.255.0 up
route add default gw 192.168.1.2
Done
m_strName->wlan0
读取到的数据:wlan0     Scan completed :          Cell 01 - Address: 0C:82:68:31:41:0B                    Protocol:802.11g/n                           
读取到的数据: Cell 07 - Address: D8:15:0D:64:1D:B8                    Protocol:802.11b/g/n                    ESSID:"GKDS_RRTT"                      0

[1]+  Done                       tqnetset -qws
[root@EmbedSky wireless]#
[root@EmbedSky wireless]# tqpda -qws &
[root@EmbedSky wireless]# Could not read calibration: "/etc/pointercal"

[root@EmbedSky wireless]#
[root@EmbedSky wireless]# Try to bring net interface up ...
0x1300 = 00064300
wpa_supplicant -B -iwlan0 -c/etc/wpa_supplicant.conf
wpa_cli -iwlan0 add_network
wpa_cli -iwlan0 enable_network 0
0x1300 = 00064300
ifconfig wlan0 192.168.1.54 netmask 255.255.255.0 up
route add default gw 192.168.1.2
Done
0x1300 = 00064300

[root@EmbedSky wireless]# ping baidu.com
PING baidu.com (220.181.57.217): 56 data bytes
64 bytes from 220.181.57.217: seq=0 ttl=54 time=932.327 ms


阅读(2785) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~