WIFI学习

开始学习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.png

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.png

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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章