开始学习WIFI相关内容,目前只了解一点WIFI 的相关名字和概念,对其实现和相关标准的了解基本为零,所以可以认为是从零学起。由于上年龄易忘事,所以强迫记录之。
一、WIFI工作的几种模式:
WIFI最常见的使用是做为WIFI热点,让其他用户以无线的方式接入构建LAN或WAN,此时WIFI也即作为AP模式,即术语中的 master模式。关于wifi的模式可以直接查看 iwconfig 命令的帮助,主要有以下几种:Ad-Hoc,Managed ,Master,Repeater,Secondary ,Monitor几种。
以下为iwconfig help中的信息
mode Setthe operating mode of the device, which depends on the net-
work topology. The mode can beAd-Hoc(network composed of only
one cell and without Access Point), Managed (node connects to a
network composed of many Access Points, with roaming), Master
(the node is the synchronisation master or acts as an Access
Point), Repeater (the node forwards packets between other wire-
less nodes), Secondary (the node acts as a backup mas-
ter/repeater), Monitor (the node is not associated with any cell
and passively monitor all packets on the frequency) or Auto.
重点描述下Ad-Hoc(点对点)模式:ad-hoc模式就和以前的直连双绞线概念一样,是P2P的连接,所以也就无法与其它网络沟通了。一般无线终端设备像PMP、PSP、DMA等用的就是ad-hoc模式。
Ad hoc网络是一种特殊的无线移动网络。网络中所有结点的地位平等,无需设置任何的中心控制结点。网络中的结点不仅具有普通移动终端所需的功能,而且具有报文转发能力。与普通的移动网络和固定网络相比,它具有以下特点:
(1)、Ad hoc网络没有严格的控制中心。所有结点的地位平等,即是一个对等式网络。结点可以随时加入和离开网络。任何结点的故障不会影响整个网络的运行,具有很强的抗毁性。
(2)、网络的布设或展开无需依赖于任何预设的网络设施。结点通过分层协议和分布式算法协调各自的行为,结点开机后就可以快速、自动地组成一个独立的网络。
与zigbee中的自组网概念类似,如果wifi要自动组网的话,就需要设置为该模式。
二、如何构造一softap:
为了实现一整套完整的soft ap需要三部分,即AP的driver(通常以firmware的方式提供)、无线AP接入和授权以及WIFI拨号三部分。
在类linux系统中,无线AP接入和授权部分主要采用的是开源的hostpad项目来实现,而WIFI拨号部分主要采用的同样是开源的wpa_supplicant,驱动部分则需要根据系统和无线芯片来决定。linux下的驱动可以参考 http://hostap.epitest.fi/ 项目中的Host AP - Linux driver for Prism2/2.5/3 ,通过三者结合来了解整个实现过程。
一)、hostapd的介绍:
开源项目hostapd官网地址为 http://hostap.epitest.fi/hostapd/,其介绍很直白,主要用于无线接入点(AP)和授权服务器(authentication servers), 不进行翻译:
hostapd is a user space daemon for access point and authentication servers. It implements IEEE 802.11 access point management, IEEE 802.1X/WPA/WPA2/EAP Authenticators, RADIUS client, EAP server, and RADIUS authentication server. The current version supports Linux (Host AP, madwifi, mac80211-based drivers) and FreeBSD (net80211).
hostapd is designed to be a "daemon" program that runs in the background and acts as the backend component controlling authentication. hostapd supports separate frontend programs and an example text-based frontend, hostapd_cli, is included with hostapd.
以下是hostapd的工作模型:
hostapd modules
二)、wpa_supplicant介绍:
wpa_supplicant is a WPA Supplicant for Linux, BSD, Mac OS X, and Windows with support for WPA and WPA2 (IEEE 802.11i / RSN). It is suitable for both desktop/laptop computers and embedded systems. Supplicant is the IEEE 802.1X/WPA component that is used in the client stations. It implements key negotiation with a WPA Authenticator and it controls the roaming and IEEE 802.11 authentication/association of the wlan driver.
wpa_supplicant is designed to be a "daemon" program that runs in the background and acts as the backend component controlling the wireless connection. wpa_supplicant supports separate frontend programs and a text-based frontend (wpa_cli) and a GUI (wpa_gui) are included with wpa_supplicant.
wpa_supplicant uses a flexible build configuration that can be used to select which features are included. This allows minimal code size (from ca. 50 kB binary for WPA/WPA2-Personal and 130 kB binary for WPA/WPA2-Enterprise without debugging code to 450 kB with most features and full debugging support; these example sizes are from a build for x86 target).
以下是wpa_supplicant的工作模型:
wpa_supplicant modules
两个模型的基本架构很相似。
三、下一步计划:
只是有了概念级别的了解,下一步需要动手操作,在linux上搭建一个自己的SOFTAP,学习如果使用这些开源工具。
另外需要重点研究下hostapd.conf文件的相关配置。
四、参考文章及资料:
1、Wireless LAN resources for Linux
http://www.hpl.hp.com/personal/Jean_Tourrilhes/Linux/Wireless.html
2、801.11协议相关文档汇总
http://wireless.kernel.org/en/developers/Documentation/mac80211
3、hostapd配置文件的示例:
http://hostap.epitest.fi/gitweb/gitweb.cgi?p=hostap.git;a=blob_plain;f=hostapd/hostapd.conf
4、Developers' documentation for wpa_supplicant and hostapd
http://hostap.epitest.fi/wpa_supplicant/devel/
5、linux下用hostapd架无线AP
http://ihacklog.com/post/use-hostapd-to-setup-wireless-access-point-under-linux.html
6、hostapd Linux documentation page
http://wireless.kernel.org/en/users/Documentation/hostapd