開始學習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)、網路的布設或展開無需依賴於任何預設的網路設施。結點通過分層協議和分布式演算法協調各自的行為,結點開機後就可以快速、自動地組成一個獨立的網路。
(3)、當結點要與其覆蓋範圍之外的結點進行通訊時,需要中間結點的多跳轉寄。與固定網路的多跳不同,Ad hoc網路中的多跳路由是由普通的網路結點完成的,而不是由專用的路由裝置完成的。(4)、Ad hoc網路是一個動態網路。網路結點可以隨處移動,也可以隨時開機和關機,這些都會使網路的拓撲結構隨時發生變化。 這些特點使得Ad hoc網路在體繫結構、網路組織、協議設計等方面都與普通的蜂窩移動通訊網路和固定通訊網路有著顯著的區別。 摘自<維基百科>
與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