无线 编程

来源:互联网 发布:大数据处理软件 编辑:程序博客网 时间:2024/06/10 14:54

1、无线中的配置工具:

 

   iwconfig:操作基本的无线参数。
 iwlist:初始化扫描频率、列表频率、比特率和密钥。
 iwspy:获得每个节点的连接质量。
 iwpriv:允许针对特定于 Wi-Fi 驱动程序的无线扩展进行操作。

2、NIC:network interface card,网卡,网络适配器的简称。

3、NDIS是Network Driver Interface Specification,即网络驱动接口规范。

     NDIS的主要目的就 是为NIC(网络接口卡,Netwok InterfaceCards)制定出标准的API接口。MAC(介质访问控制,Media Access Controller)设备驱动封装了所有的NIC硬件实现,这样一来所有的使用相同介质的NIC就可以通过通用的编程接口被访问。NDIS同时也提供一个函数库(又时也称作wrapper),这个库中的函数可以被MAC驱动调用,也可以被高层的协议(例如TCP/IP)驱动调用。这些wrapper函数使得MAC驱动和协议驱动的开发变得更加容易。同时,这些wrapper函数也减 少了驱动程序对工作平台的依赖性。

4、OID:对象术语中,叫做对象标识(Object identifier-OID),通常OID在内部都使用一个或多个大整数表示,而在应用程序中则提供一个完整的类为其他类提供获取、操作。

5、struct info是存储AP信息的结构体

struct info{
    int index;            //第几个cell
    char enc_PassWordKeyIndex[8];
    char channel[8];     // 8B
    char rssi[8];        // 8B
    char essid[64];             // 36B id号
    //unsigned long essidlength;
    char macAddr[32];        // 18B mac地址字符串
    char enc[16];            // 12B
    char auth[32];      // 20B
    char networktype[32]; //12B 
    char Quality[16];        //通信质量百分比的分子
    char signalLevel[16];        //信号强度
    char noiseLevel[16];        //噪音强度    
    char encryDataType[32];    
    char passWordKeyIndex_1[64]; //wep key 1-4
    char enc_PassWordKey[128];  // share password
};

 

6、频道:就和电视信号一样,如果都同一频段,会冲突的,所以设置了一共11个频段,供用户选择。

7、基本过程(rt73):

    (1)ifconfig -a查看无线硬件是否被系统识别(ifconfig不能识别)

    (2)iwconfig rausb0 up(需手工启动)

    (3)iwlist rausb0 scanning(检查ap)

            如果没有第二步,则提示:“rausb0    Interface doesn't support scanning : Network is down”

    (4)使用ifconfig rausb0 对IP NETMASK等进行配置。 

    (5)iwpriv rausb0 set EncrypType=WEP
    (6)iwpriv rausb0 set DefaultKeyID=1

    (5)iwconfig rausb0 essid "AP‘Name"

8、

The driver is built as part of the kernel and ends up in the finalfirmware with all the other drivers. However i have not added into theinit scripts the commands to load it automatically. You can load itanytime by doing

 insmod rt73

or with debug information (lots of it) with

 insmod rt73 debug=2

I have also enabled in the default ntosd-dm320_defcofig kernelconfig script the option CONFIG_NET_RADIO, so the Linux wirelessextension are in place. If you get a strange message of symbols notdefined when you load this module, try double checking you have rebuiltyour kernel with that option active.

This creates a new network interface called rausb0 (you see itin iwconfig).If you want to manipulate this interface in any way with the wirelesstools (see below), you first neet to bring it up. The following will bethe minimum needed to do it:

 ifconfig rausb0 up

Of course you might want to set an IP address and netmask for it, but you can always do that later.

[edit] Wireless tools

I checked into the tree the latest version of Linux wireless tools(linux-r3-extra-apps/wireless_tools.28) and enabled their automaticbuild when using neuros-bsp/build-helper.sh

The tools end up in /sbin on the final root file system and take up only around 56K (due to the multicall binary design).

You use these tools to setup wireless specific network parameters, as explained below

[edit] Setting up wireless network

The driver can work in different configurations, but we'll look onlyat managed mode here, which allows to associate the dongle with anAccess Point (AP) and thus enter in its wireless network. So firstthing we need to do is to bring the dongle in managed mode:

 iwconfig rausb0 mode managed

Then you can check for wireless networks around you by asking the driver to give you a site survey with:

 iwpriv rausb0 get_site_survey


This outputs a list of all access points available in the area. Ifyou don't see anything, you might want to wait 20 seconds or so afteryou bring up the rausb0 interface, so that it has time to scan the airfor networks.

The basic things you need to do for all types of networks aresetting the channel and the networks SSID (i.e. the network name) towhich you want to connect (you can get these two values from the sitesurvey above):

 iwconfig rausb0 essid YOUR_NETWORK

iwconfig rausb0 channel N

If the network is open, if you wait some seconds and then ask

 iwconfig rausb0 

If you see a line that has "Access point: SOMETHING" in it, then you're up and associated.

If the network has WEP authentication, to associate with the AP you need to authenticate this way:

 iwpriv rausb0 set AuthMode=WEPAUTO

iwpriv rausb0 set EncrypType=WEP

iwpriv rausb0 set Key1="YOUR_WEP_PASSWORD"

iwpriv rausb0 set SSID="YOUR_NETWORK"

The parameter in YOUR_NETWORK is the same you used above with iwconfig.

And if the network has WPA authentication, you need to do this instead:

 iwpriv rausb0 set AuthMode=WPAPSK

iwpriv rausb0 set EncrypType=TKIP

iwpriv rausb0 set WPAPSK="YOUR_WPA_PASSWORD"

iwpriv rausb0 set SSID="YOUR_NETWORK"

This is for WPA with pre-shared key (PSK). This is the most commonusage in residential and SOHO setups. Some office setups use WPA Radiusto authenticate, but I don't know how to setup that and I doubt we willneed to know initially.

原创粉丝点击