无线 编程

1、无线中的配置工具:

 

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

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

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

     NDIS的主要目的就 是为NIC(网络接口卡,Netwok Interface Cards)制定出标准的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 final firmware with all the other drivers. However i have not added into the init scripts the commands to load it automatically. You can load it anytime 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 kernel config script the option CONFIG_NET_RADIO, so the Linux wireless extension are in place. If you get a strange message of symbols not defined when you load this module, try double checking you have rebuilt your kernel with that option active.

This creates a new network interface called rausb0 (you see it in iwconfig). If you want to manipulate this interface in any way with the wireless tools (see below), you first neet to bring it up. The following will be the 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 automatic build 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 only at managed mode here, which allows to associate the dongle with an Access Point (AP) and thus enter in its wireless network. So first thing 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. If you don't see anything, you might want to wait 20 seconds or so after you bring up the rausb0 interface, so that it has time to scan the air for networks.

The basic things you need to do for all types of networks are setting the channel and the networks SSID (i.e. the network name) to which you want to connect (you can get these two values from the site survey 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 common usage in residential and SOHO setups. Some office setups use WPA Radius to authenticate, but I don't know how to setup that and I doubt we will need to know initially.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值