User Tools

Site Tools


doc:appunti:linux:sa:wifi_pccard

WiFi con Linux e adattatori PC-Card o USB

Appunti sul funzionamento di alcuni adattatori WiFi PC-Card e USB su Debian Etch GNU/Linux kernel 2.6.18. Argomenti interessanti:

  • Compatibilità: kernel Linux standard, moduli kernel extra, driver Windows con NDIS wrapper.
  • Possibilità di crittografia WEP e WPA.
  • Compatibilità con programmi di monitoraggio Kismet, SWScanner e Wavemon.
Hardware Driver Mode Managed Mode Master WEP encryption WPA key negotiation Use as Kismet source iwlist signal/noise monitor
Sitecom USB 54g Turbo WL-172 rt73usb Linux kernel module Yes Yes (104 bit) WPA-PSK via iwpriv, EAPOL 1 and 2 rt2500 Not in scanning mode (iwlist or SWScanner). Quality and Signal level are reported by iwconfig only when associated to an AP.
Avaya Wireless PC Card ETS (Gold) orinoco Linux kernel module Yes Yes (104 bit) No orinoco_14
Avaya Wireless PC Card ETS (Gold) Windows ndis driver No No No No
U.S. Robotics 22 Mbps Wireless PC Card (USR2210) acx kernel module by acx100.sourceforge.net No No No No
U.S. Robotics 22 Mbps Wireless PC Card (USR2210) Windows ndis driver Yes Yes (104 bit) No No
Leaptek WiFi USB zd1211rw Linux kernel module Yes No zd1211 (not reliable) Quality and RSSI Signal level (poor resolution)
Intel Corporation PRO/Wireless 2200BG ipw2200 Yes ipw2200 (no signal levels) Quality and Signal level

Sitecom Wireless Network USB Adapter 54g Turbo WL-172

The USB stick is detected by the Linux kernel as follows:

# lsusb
Bus 001 Device 002: ID 0df6:90ac Sitecom Europe B.V.

A kind guy from the Sitecom support - whose name is Ivan - told me that the WiFi chip inside is a Ralink rt2561, I'm not very sure of this: as far I know the rt2561 chip is found on PCI and PC-Card adapters, where USB adapters mount the rt2573 chip.

Kernel modules rt2x00

NOTE wireless modules rt2x00 are now in the vanilla kernel (at least in 2.6.26). We use the rt73usb one.

Compiling this modules requires the the source tree of your running kernel, and the relative kernel headers. In Debian this menas installing two packages: linux-source-$(uname -r | cut -f1 -d-) and linux-headers-$(uname -r).

We tried the driver from the rt2x00 Open Source Project. This driver is not part of the vanilla Linux kernel, but it compiles with version 2.6.17 (we succeeded with 2.6.18).

Initially we tried the experimental unified driver rt2x00, which includes several kernel modules for rt2400pci, rt2500pci, rt2500usb, rt61 and rt73usb, but we was unable to compile it. We set CONFIG_RT2X00_DEBUGFS=n into the config file because in our kernel CONFIG_DEBUG_FS is not set, after the make we got a fatal error: expected specifier-qualifier-list before ‘irq_handler_t’.

So next we tried the specific rt73 driver from the daily CVS tarball (here a local copy dated 2007-03-27), this time the compile succeeded:

wget http://rt2x00.serialmonkey.com/rt73-cvs-daily.tar.gz
tar zxf rt73-cvs-daily.tar.gz
chown -R root.root rt73-cvs-2007030410
cd rt73-cvs-2007030410/Module
make

When the wireless interface is activated, the rt73.ko kernel module searches for two files: the firmware rt73.bin to be uploaded to the adapter and the default configuration file rt73sta.dat. Both files are expected to be into the /etc/Wireless/RT73STA/ directory. This directory name is quite odd, we prefer /usr/local/lib/firmware/ and some symbolic links:

mkdir -p /usr/local/lib/firmware
mkdir -p /etc/Wireless/RT73STA
cp -p rt73.bin /usr/local/lib/firmware
cp -p rt73sta.dat /usr/local/lib/firmware
chmod 640 /usr/local/lib/firmware/rt73sta.dat
ln -s /usr/local/lib/firmware/rt73.bin /etc/Wireless/RT73STA/rt73.bin
ln -s /usr/local/lib/firmware/rt73sta.dat /etc/Wireless/RT73STA/rt73sta.dat

Finally we installed the kernel module:

make install

This install the file /lib/modules/2.6.18/extra/rt73.ko, run the command depmod and add a file /etc/modprobe.conf containing this line:

alias ra0 rt73

Because this alias is rather useless, we removed it.

Mode Managed

Using the WiFi adapter in Managed mode is as simple as issuing:

modprobe rt73
ifconfig rausb0 up
iwconfig rausb0 essid any mode managed key 's:wep_secret'

The driver supports WEP keys of 40 or 104 bits (5 or 13 characters), as reported by iwlist:

# iwlist rausb0 encryption
rausb0    2 key sizes : 40, 104bits
          4 keys available :
                [1]: 3892-0604-F842-8032-D771-00AE-63 (104 bits)
                [2]: off
                [3]: off
                [4]: off
          Current Transmit Key: [1]

WPA key management

See this excellent post.

This driver supports the WPA key management with WPA-PSK (pre-shared key) without the need of the wpa_supplicant utility. We must provide the WPA configuration via the rt73sta.dat configuration file or using the iwpriv command: refer to the iwpriv_usage.txt file included into the driver tarball for options that can be specified in both ways.

For a WPA connection, set at least the following options into rt73sta.dat before activating the interface:

SSID=my_ssid
NetworkType=Infra
AuthMode=WPAPSK
EncrypType=TKIP
WPAPSK=wpa_secret

Note that Infrastructure is an alias for Managed mode. Alternatively, run the following commands directly or through a shell script:

modprobe rt73
ifconfig rausb0 up
iwpriv rausb0 set NetworkType=Infra
iwpriv rausb0 set AuthMode=WPAPSK
iwpriv rausb0 set EncrypType=TKIP
iwpriv rausb0 set SSID=my_ssid
iwpriv rausb0 set WPAPSK=wpa_secret

The negotiated key seems to be 256 bits:

# iwlist rausb0 key
rausb0    2 key sizes : 40, 104bits
          4 keys available :
                [1]: 95CB-3C00-EBDE-4296-4037-6A56-CCCF-561E-7A43-A328-9A03-A5AD-3010-A33E-EC99-DCAD (256 bits)
                [2]: EC3E-59AB-3B48-9708-7693-A1BE-4487-3E4B-3D0C-286D-82D7-928A-B538-500A-BFD7-3AD1 (256 bits)
                [3]: off
                [4]: off
          Current Transmit Key: [1]

There was a problem in the rt73 driver before 2007-03-21 with access points that announce - in their 802.1x frames - an Extensible Authentication Protocol over LAN (EAPOL) version different than 1. This is the case - for example - of many access points based on embedded Linux and the hostap program, which currently announces EAPOL version 2.

It should be responsability of the client (the supplicant) to manage different EAPOL versions, but early versions of the driver had a #define EAPOL_VER 1. In more recent snapshots the problem is solved.

Kismet and rfmon mode

The adapter works fine also in rfmon mode (a special mode that reports all packets the wireless card sees, including management packets and packets from any network the radio can see). So Kismet can works with it, just configure the source as a Ralink 2500 into /etc/kismet/kismet.conf:

source=rt2500,rausb0,rausb0

Avaya Wireless PC Card ETS (Gold)

Driver nativi kernel

Funziona almeno in modalità managed e con crittografia WEP, purtroppo non funziona la crittografia WPA perché non supportata dal modulo kernel.

Con la scheda Avaya si utilizzano i moduli nativi del kernel orinoco, orinoco_cs e hermes. La scheda viene riconosciuta correttamente, l'hotswap può essere forzato con pccardctl {insert|eject}.

Per attivare la scheda non è necessario alcun firmware, si usa un comando del tipo:

pccardctl insert
iwconfig eth1 essid any mode Managed key off
ifup eth1

Driver Windows con ndiswrapper

Non funziona: la scheda non viene riconosciuta come periferica PCI e non viene evidenziata da lspci -n.

Il tentativo (fallito) di caricare il driver Windows con ndiswrapper prevede di mettere in blacklist i moduli nativi del kernel e mettere un alias per il device wlan0 che carichi ndiswrapper:

cat >> /etc/modprobe.d/ndiswrapper << EOF
alias wlan0 ndiswrapper
blacklist orinoco_cs
blacklist orinoco
blacklist hermes
EOF
reboot

A questo punto si lancia ndiswrapper indicando il file .INF da caricare, ma si ha un errore:

ndiswrapper -i WLAGS48B.INF
ndiswrapper -l
wlags48b invalid driver!
modprobe wlan0

U.S. Robotics 22 Mbps Wireless PC Card (USR2210)

Questa scheda dovrebbe essere basata sul chip Texas Instruments (TI) ACX100.

Driver Windows con ndiswrapper

Funziona almeno in modalità managed, non funziona la crittografia WPA. Quando la scheda è inserita viene vista come periferica PCI:

pccardctl insert
lspci -n
...
05:00.0 0280: 104c:8400

Si è scaricato il driver per Windows XP USR03_307_v3.0.0.0_4x fornito dal sito ufficale U.S. Robotics. Per scompattare l'archivio autoinstallante si è usato cabestract e unshield, quindi in una stessa directory (es: /lib/firmware/usrwlan/) si sono radunati tutti i driver ed il file .INF per Windows XP:

  • RADIO0d.BIN
  • RADIO11.BIN
  • USRWLAN.CAT
  • USRWLAN.INF
  • USRWLAN.SYS
  • WLANGEN.BIN

A questo punto si esegue:

ndiswrapper -i USRWLAN.INF
ndiswrapper -l
installed drivers:
usrwlan         driver installed, hardware (104C:8400) present

Si verifica che wlan0 sia un alias di ndiswrapper in /etc/modprobe.d/ndiswrapper

alias wlan0 ndiswrapper

quindi si carica il modulo e si configura la periferica WiFi:

modprobe wlan0
ifconfig wlan0 up
iwconfig wlan0 essid any mode Managed key s:wep_secret key open
ifup wlan0

Appena rilevato l'access point, la scheda viene automaticamente configurata:

# iwconfig wlan0
wlan0     IEEE 802.11b  ESSID:"default"
          Mode:Managed  Frequency:2.437 GHz  Access Point: 00:0D:88:F2:7D:CE
          Bit Rate:22 Mb/s   Tx-Power:0 dBm   Sensitivity=0/3
          RTS thr:4096 B   Fragment thr:4095 B
          Encryption key:3132-3334-3536-3738-3930-3132-33   Security mode:open
          Power Management:off
          Link Quality:71/100  Signal level:-50 dBm  Noise level:-96 dBm
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:0   Missed beacon:0

Pare che la crittografia WPA non sia supportata dal driver Windows: appena si carica il modulo, dentro kern.log si legge:

ndiswrapper version 1.28 loaded (preempt=no,smp=no)
ndiswrapper: driver usrwlan (U.S.Robotics,02/25/2003,3.0.0.0) loaded
PCI: Enabling device 0000:05:00.0 (0000 -> 0003)
ndiswrapper: using IRQ 9
wlan0: vendor: 'USR 22M WLAN Adapter'
wlan0: ethernet device 00:c0:49:a7:b0:9e using NDIS driver usrwlan, 104C:8400.5.conf
wlan0: encryption modes supported: none
usbcore: registered new driver ndiswrapper

Il tentativo (fallito) di usare WPA:

wpa_passphrase MyPlace 8702024407 > /etc/wpa_supplicant.conf
wpa_supplicant -Dndiswrapper -iwlan0 -dd -c /etc/wpa_supplicant.conf
...
...
Selecting BSS from priority group 0
0: 00:18:84:20:a3:2a ssid='MyPlace' wpa_ie_len=0 rsn_ie_len=0 caps=0x11
   skip - no WPA/RSN IE
1: 00:18:84:20:a3:29 ssid='FON_AP' wpa_ie_len=0 rsn_ie_len=0 caps=0x1
   skip - no WPA/RSN IE
No suitable AP found.

Il problema dell'accesso WPA rimane anche con i driver WindowsXP dwl650+_drivers_307 della scheda D-Link DWL 650+, basata sullo stesso chip. Pare che i driver per Windows supportino WPA, ma dopo averli caricati con ndiswrapper (il driver si chiama airplus) l'esecuzuione di wpa_supplicant restituisce:

Driver does not support WPA.

Driver kernel open source

Non funziona. Si sono provati i driver acx-20070101 per kernel 2.6.x (sito di riferimento acx100.sourceforge.net), ma non inclusi nel kernel ufficiale.

Compilati dentro /usr/src/linux/ come da istruzioni.

Il firmware è stato preso dall'archivio dei driver Windows di cui sopra, sono stati utilizzati due file: quello generico per il chip ACX100 e quello specifico per il tipo di radio (il tipo di radio viene rilevato al caricamento del modulo acx.ko).

cp DrvXP/WLANGEN.BIN /lib/firmware/tiacx100
cp DrvXP/RADIO11.BIN /lib/firmware/tiacx100r11
insmod /usr/src/linux/drivers/net/wireless/acx/acx.ko

Il kernel fornisce messaggi positivi, purtroppo però non funziona neanche in modalità managed senza crittografia.

Leaptek WiFi USB (zd1211b chip)

Adattatore WiFi USB basato sul chip ZyDAS ZD1211B. Utilizza il modulo kernel zd1211rw, ha bisogno di una copia del firmware nella directory /lib/firmware/zd1211/.

Dopo aver inserito l'adattatore nella porta USB questi i messaggi mostrati da dmesg:

usb 3-1: new high speed USB device using ehci_hcd and address 10
usb 3-1: configuration #1 chosen from 1 choice
zd1211rw 3-1:1.0: firmware version 4725
zd1211rw 3-1:1.0: zd1211b chip 0ace:1215 v4810 high 00-02-72 AL2230_RF pa0 g--
zd1211rw 3-1:1.0: eth1

Poi è possibile attivare l'interfaccia, effettuare lo scanning, ecc:

# ifconfig eth1 up

# iwconfig eth1
eth1      802.11g zd1211  ESSID:off/any
          Mode:Managed  Frequency:2.472 GHz  Access Point: Invalid
          Bit Rate=1 Mb/s
          Encryption key:off
          Link Quality:0  Signal level:0  Noise level:0
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:0   Missed beacon:0

# iwlist eth1 scanning
eth1      Scan completed :
          Cell 01 - Address: 00:18:0A:01:3E:39
                    ESSID:"MyWIFI"
                    Protocol:IEEE 802.11bg
                    Mode:Master
                    Channel:5
                    Encryption key:off
                    Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 6 Mb/s; 9 Mb/s
                              11 Mb/s; 12 Mb/s; 18 Mb/s; 24 Mb/s; 36 Mb/s
                              48 Mb/s; 54 Mb/s
                    Quality=100/100  Signal level=100/100
                    Extra: Last beacon: 490ms ago
          Cell 02 - Address: 00:C0:49:A6:9C:14
                    ESSID:"pipnet"
                    Protocol:IEEE 802.11b
                    Mode:Master
                    Channel:5
                    Encryption key:on
                    Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 22 Mb/s
                    Quality=100/100  Signal level=100/100
                    Extra: Last beacon: 570ms ago
          Cell 03 - Address: 00:13:46:A0:2C:09
                    ESSID:"tnle"
                    Protocol:IEEE 802.11b
                    Channel:13
                    Encryption key:off
                    Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 22 Mb/s
                    Quality=100/100  Signal level=47/100
                    Extra: Last beacon: 1090ms ago

Con il modulo zd1211rw del kernel 2.6.26 vengono attivati due device, un wmaster0 (l'interfaccia fisica) e un wlan0_rename (l'interfaccia logica WiFi da usare con iwconfig e ifconfig). Per dare un nome umano al device conviene aggiungere una riga in /etc/udev/rules.d/70-persistent-net.rules, per effettuare il match non basta il MAC address, serve anche ATTR{type}==“1”:

# USB device 0ace:1215 ZyDAS WLA-54L WiFi
SUBSYSTEM=="net", DRIVERS=="?*", ATTR{address}=="00:1a:ff:01:4b:2e", ATTR{type}=="1", NAME="eth2"

WiFi Management Tools

Esistono alcuni tool grafici per gestire lato utente le connessioni WiFi, in generale sono interfacce grafiche ai comandi iwlist, iwconfig, ifconfig, dhclient, ecc. Ecco una tabella comparativa:

NetworkManager È l'applet predefinita dell'ambiente Gnome, intende gestire sia le connessioni Ethernet che WiFi. Architettura client/server: knetworkmanager è il client per KDE. Secondo me cerca di fare troppe cose in automatico e mi pare che gli automatismi non siano disattivabili. Esegue continuamente lo scanning cambiando eventualmente la connessione al volo. Comoda la possibilità di essere eseguito dall'utente non privilegiato, basta che appartenga al gruppo netdev.
wpa_gui wpa_supplicant può essere usato come demone con i client wpa_gui e wpa_cli per gestire tutte le connessioni WiFi, non solo quelle WPA. È possibile La gestione da parte di utenti non privilegiati che appartengono ad un determinato gruppo (parametro ctrl_interface GROUP in wpa_supplicant.conf). È possibile anche permettere agli utenti il salvataggio delle impostazioni a livello globale (es. aggiunta di nuove reti) mettendo update_config=1 nel file di configurazione; forse era meglio un file personalizzato per ogni utente, come fa NetworkManager.
wicd Si presenta come progetto nuovo, agnostico rispetto al Desktop Environment, gestisce connessioni wired e WiFi, WEP e WPA, dispone di applet per systray. Pare che ancora non sia pacchettizato Debian.
kwifimanager Ben integrato con KDE, sarebbe buono, peccato che non supporti le connessioni WPA! Per effettuare operazioni privilegiate chiede la password di root.
wifi-radar Anche questo tool non supporta del tutto WPA, ad esempio la PSK deve essere inserita manualmente in wpa_supplicant.conf. Inoltre effettua una continua scansione delle reti WiFi, consumando batteria e risorse.
doc/appunti/linux/sa/wifi_pccard.txt · Last modified: 2009/04/18 16:42 by niccolo