Helping ordinary people create extraordinary websites!
GET OUR NEWSLETTER
Your Email:
 

Linux Wireless Networking

By Sreekrishnan Venkateswaran
2005-05-04


Linux 802.11 WLAN

A WLAN communication system acts as an alternative to wired LAN and is generally used within a building. WLAN uses the ISM (Industrial, Scientific, Medical) radio-band frequency for communication. WLAN's 802.11a standard uses the 5 GHz band and supports a maximum speed of 54 Mbps, while the 802.11b and the 802.11g standards use the 2.4 GHz band and support maximum speeds of 11 Mbps and 54 Mbps, respectively.

WLAN resembles wired Ethernet in that both are assigned MAC (Media Access Control) addresses from the same address pool and both appear to the operating system network-device layer as Ethernet devices. For instance, ARP (Address Resolution Protocol) tables are populated with WLAN MAC addresses alongside Ethernet MAC addresses.

WLAN and wired Ethernet, however, differ significantly at the link layer. The 802.11 standard, for example, uses collision avoidance (CSMA/CA) instead of collision detection (CSMA/CD) used by wired Ethernet. Moreover, WLAN frames, unlike Ethernet frames, are acknowledged.

Because of fuzzy boundaries between WLAN stations, the WLAN link layer has a protocol to clear out an area before transmission. For security, WLAN's Wired Equivalent Privacy (WEP) encryption mechanism provides a level of security equivalent to wired networks. WEP combines a 40-bit or a 104-bit key with a random 24-bit initialization vector to encrypt/decrypt data. WLAN supports two modes of communication: Ad Hoc mode for communication between a small group of stations for a short period of time without using an access point, and Infrastructure mode where all communication passes through an access point. Access points periodically broadcast a Service Set Identifier (SSID) that identifies one WLAN network from another.

Most available WLAN cards are either based on the Intersil Prism chipset or the Lucent Hermes chipset. Compaq, Nokia, Linksys, and D-Link cards use the Prism chipset, while the Lucent Orinoco card and the Apple Airport use the Hermes chipset.

Linux WLAN support
Linux support for WLAN broadly consists of a WLAN API implementation and WLAN device drivers. I'll look at them in turn.

Two Linux projects define a generic WLAN API and provide tools to let user-space applications configure parameters and access information from WLAN device drivers. The Wireless Extensions project provides a common Linux user space interface for different wireless cards. The project's tools include iwconfig to configure parameters like WEP keys and SSIDs in the WLAN driver. The linux-wlan project, for its part, also supports a set of tools that talk to WLAN device drivers from user space. These utilities, unlike the ones based on Wireless Extensions, use an SNMP (Simple Network Management Protocol) MIB (Management Information Base)-like syntax that mirrors the IEEE 802.11 specification. (See Resources for more on the projects.)

Moving on to device drivers, the Linux device drivers that support popular WLAN cards include:

• The Orinoco WLAN driver: Part of the Linux kernel sources, supports both Hermes-based cards and Intersil Prism-based cards. The orinoco_cs module provides PCMCIA card services support needed for PCMCIA and CF cards.

• The linux-wlan project's linux-wlan-ng driver: Supports a variety of cards based on the Prism chipset. The driver supports the linux-wlan API and partially supports Wireless Extensions.

• The Host AP device driver: Supports the Host AP mode of Prism chipsets that lets a WLAN host act as an access point.

• The Linux Symbol Spectrum device driver: Supports Symbol PCMCIA cards. The Symbol CF card, unlike the PCMCIA card, lacks firmware on the card and depends on the device driver to download the firmware. A separate version of the driver works for the CF card. Intel repackages the Symbol PCMCIA card as the Intel PRO/Wireless card, while Socket communications repackages the Symbol CF card.

• The Atmel USB WLAN driver: Supports many USB WLAN devices using Atmel chipsets.

See Resources for information on drivers for these devices.

The Intersil Prism2 WLAN CF card
I'll review the Intersil Prism2 802.11b WLAN CF card to show you how it works with the Linux PCMCIA, network devices, and protocol layers.

The Linux PCMCIA/CF layer consists of device drivers for PCMCIA host controllers, client drivers for different cards, user mode programs, daemons that aid hot plugging, and a kernel card-services core that interacts and provides services to all of the above (see Resources). The PCMCIA controller bridges the card to the system bus. It maps card memory to host I/O and memory windows and routes interrupts generated by the card to a free processor interrupt line. CF cards are smaller, but compatible with PCMCIA, and are frequently used in handheld devices. PCMCIA/CF cards have two memory spaces: attribute memory and common memory. Attribute memory holds configuration registers and descriptor information like the Card Information Structure (CIS). The Linux card services core interacts with the host controller device driver, the card device drivers, and the user mode cardmgr daemon. It invokes the card driver's event handler routine during events like card insertion, card removal, and low battery. Whereas card services passes information up to cardmgr from the card's CIS, cardmgr passes down to card services the resource allocation policy defined in user space (/etc/pcmcia/config.opts) for allocating memory windows and interrupt levels. Look at drivers/pcmcia/ds.c to see the kernel code that interacts with cardmgr and refer to /etc/pcmcia/config.opts to see the user space resource allocation policies.

When the Intersil WLAN CF card is inserted, card services invokes the orinoco_cs module's PCMCIA event handler. Card services parses the CIS tuples in the card attribute memory and passes the information up to cardmgr, which loads the appropriate device drivers from the /etc/pcmcia/config file (see Listing 1). Because the manfid tuple in the card's CIS matches the entry in /etc/pcmcia/config, cardmgr binds the card with the orinoco_cs driver. The device entry in Listing 1 states that the orinoco_cs driver consists of three kernel modules: orinoco, orinoco_cs, and hermes. Also, because the device is of class wireless, cardmgr executes the script /etc/pcmcia/wireless while starting and stopping the device. The script uses WLAN tools and utilities to configure device driver parameters like WEP keys and SSIDs. It can also start networking protocols like DHCP (Dynamic Host Configuration Protocol) over the WLAN. The example in Listing 1 uses Wireless Extensions tools to perform device configuration.

Note: The exact location of the PCMCIA configuration files depends on the Linux distribution used.

Listing 1. PCMCIA device entries for the Intersil WLAN CF card

card "Intersil PRISM2 11 Mbps Wireless Adapter"

manfid 0x0156, 0x0002
bind "orinoco_cs"


device "orinoco_cs"
class "wireless" module "orinoco","orinoco_cs","hermes"
Parameters like WEP keys and SSIDs are configured using the /etc/pcmcia/wireless and the /etc/pcmcia/wireless.opts scripts.

Listing 2. Configuring WLAN specific parameters

iwconfig ethX essid <wlan_name> 

key AAAA-AAAA-AA [1] key BBBB-BBBB-BB [2] key CCCC-CCCC-CC [3] key DDDD-DDDD-DD [4]
: Set 64-bit WEP Keys and ESSID in the driver
iwconfig ethX : Display WLAN parameters
iwpriv : Get nongeneric, driver-specific parameters
iwlist : List Information and statistics from an interface
iwspy : Read quality of link for a set of addresses
/proc/net/wireless : Wireless Statistics from the device driver
During card insertion, orinoco_cs, like legacy network device drivers, invokes register_netdev to get an ethX network interface name assigned to the WLAN interface. It also registers an interrupt service routine's address to service interrupts generated when wireless data is sent or received. The interrupt handler is part of the orinoco module and interacts with the Linux networking stack. The key data structure used by the Linux networking stack is the sk_buff structure (defined in include/linux/skbuff.h, (see Resources), which contains control information about a block of memory attached to it. sk_buffs provide efficient buffer handling and flow control mechanisms for all networking layers. Network device drivers do an dev_alloc_skb and an skb_put to populate an sk_buff with IP data, and then pass it on to the TCP/IP stack by invoking netif_rx. The orinoco interrupt service routine populates sk_buffs with data received from the WLAN and passes it on to the IP stack via netif_rx.

Linux TCP/IP applications can run unchanged over the network interface provided by the kernel modules mentioned earlier for the Intersil WLAN CF card.

Tutorial Pages:
» A Look at WLAN, Bluetooth, GPRS, GSM, and Infrared Data on Linux
» Linux 802.11 WLAN
» Linux Bluetooth
» Linux GPRS and Data over GSM
» Linux Infrared Data
» Performance Issues
» Conclusion
» Resources


First published by IBM DeveloperWorks


 | Bookmark
Related Tutorials:
» Secrets of the Wireless Elite: Alexei Polyakov
» A New Strategy of Language Pack Management for Wireless Apps
» Open Source Wireless Tools Emerge
» Getting Practical About Wireless Security, Part 1: Building a Wireless Sniffer with Perl
» Challenges and Opportunities in Mobile Games
» Running Linux on an iPAQ

Advertise with Us!


Tutorials Scripts Web Hosting Developer Manuals
Resources