一、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