MadWifi

From Gentoo-en
Jump to: navigation, search

Introduction

MadWifi is short for Multiband Atheros Driver for Wireless Fidelity. The MadWifi drivers provide support for a wide range of Atheros wireless network devices.

The driver works such that your wireless device will appear as a normal network interface in the system. Additionally there is support for the Wireless Extensions API. This allows you to configure most aspects of the device using common (wireless) network tools (ifconfig, iwconfig and friends).

For a list of devices known to be compatible with MadWifi, see the MadWifi compatibility page.

Note: the domain http://madwifi.org is not controled by the madwifi team. Please use http://madwifi-project.org instead.

Installation

Make sure you have compiled your kernel with the following options (note that the location of options in your kernel may differ).

Linux Kernel Configuration: Linux Kernel Configuration: MadWifi kernel options (before 2.6.22)
  Loadable module support
    [*] Enable loadable module support
    [*] Module unloading
    [*] Automatic kernel module loading
  Device Drivers
    [*] Networking support
    Wireless LAN (non-hamradio) --->
      [*] Wireless LAN drivers (non-hamradio) & Wireless Extensions
Linux Kernel Configuration: Linux Kernel Configuration: MadWifi kernel options (2.6.22 to 2.6.32)
  Loadable module support
    [*] Enable loadable module support
    [*] Module unloading
    [*] Automatic kernel module loading
  Networking
    Wireless
      [*] Wireless extensions: enabled 
Linux Kernel Configuration: Linux Kernel Configuration: MadWifi kernel options (2.6.33 and later)
  [*] Enable loadable module support --->
     [*]   Module unloading
  [*] Networking support  --->
    [*]   Wireless  --->
  Device Drivers  --->
    [*] Network device support  --->
    [*]   Wireless LAN  --->
      <M>   Intel PRO/Wireless 2100 Network Connection ( 'or select as module another extension from the list needing WIRELESS_EXT')

Note: on kernel >= 2.6.33, you need absolutly to select a driver in the kernel (like Intel Wireless 2100) that need WIRELESS_EXT=y, even if you don't need this driver.

After ensuring that you have fulfilled the MadWifi requirements, install the madwifi-ng package with:
emerge --ask --verbose madwifi-ng madwifi-ng-tools

The kernel module for modprobe is "ath_pci".

Using your Device as an Access Point

This is only about configuring your card to operate as an access point. See Wireless/Access point for information on NAT-forwarding, bridging and WEP/WPA encryption.

Your card will enter standard mode by default, but you need to bring the driver up in master mode. To accomplish this, you need to edit the module options. Note that the default behavior of etc-update will be to remove this customization, so remember to do what is necessary to keep your changes after re-emerging madwifi-ng (say, after a kernel compile).

File: /etc/modprobe.d/ath_pci
options ath_pci autocreate=ap
You will now need to run:
update-modules

It's also possible to set the driver into master mode without needing to reload the module itself. This way, you have to take the interface down, destroy it, and rebuild it in the new mode, which goes by the name ap rather than master. Here's how it works:

ifconfig ath0 down wlanconfig ath0 destroy wlanconfig ath0 create wlandev wifi0 wlanmode ap

You could also skip the 0 in the last command, as wlandev will choose the first available integer if none is supplied. The benefit of this tool seems to be that you can create an arbitrary number of virtual ath interfaces, which could presumably be used to service multiple separate LANs with different access control and/or features. In any case, once you've created the new device in mode 'ap' you should see it in the output from iwconfig and it should say Mode:Master.

Note that in all the rest of the configuration you should use the 'ath0' device, rather than 'wifi0' which appears to just be a container for the rest of the stuff.

File: /etc/conf.d/net
postup() {
	if [ $1 == "ath0" ] ; then
		# Set txpower to 6
		# iwconfig ath0 txpower 6

		# Disable antenna diversity (prevent MadWifi from throwing a kernel panic, see bug #1998) and fix weak signal strength problem
		sysctl -w dev.wifi0.diversity=0
		sysctl -w dev.wifi0.txantenna=1
		sysctl -w dev.wifi0.rxantenna=1
	fi

	return 0
}

# net.ath0 will not work if you use the preup- or postup function to set the values of mode_ath0, essid_ath0 and config_ath0. You must set them here manually.

# set ath0 into access point mode ("master")
mode_ath0="master"

# master mode requires an ESSID
essid_ath0="Tux"

# If you do not set this variable, the init.d script tries to obtain one via DHCP, so we need to specify the access point's IP here
# THIS MUST NOT EXIST IN BRIDGED MODE; COMMENT IT OUT OR SET IT TO NULL INSTEAD 
config_ath0=(
	"192.168.0.1 netmask 255.255.255.0"
)
# Note: ifconfig_ath0 is deprecated, use config_ath0 instead

# Set the channel (1-14)
channel_ath0="8"

iwpriv_ath0=(
	# Set the card's 802.11a/b/g mode:
	# Mode 0 = Autoselect (this mode will automatically detect the client's mode and change to it)
	#      1 = 802.11a
	#      2 = 802.11b
	#      3 = 802.11g
	"mode 0"

	# Enable turbo mode (only available in 5 GHz frequency range)
	# "turbo 1"

	# Disabling background scanning (fixes "stuck beacon" problem; see bug #1017)
	# This also increases the performance (see http://madwifi-project.org/wiki/UserDocs/PerformanceTuning)
	"bgscan 0"

	# Disable fast frames and bursting
	# "ff 0"
	# "burst 0"

	# Disable 802.1g Protection Mode
	"protmode 0"

	# Set the RSSI threshold for 802.11a/b/g mode to 11
	"rssi11a 11"
	"rssi11b 11"
	"rssi11g 11"

	# See bug #1957
	# "bmiss 50"

	# Reduce the beacon interval time (see http://madwifi-project.org/wiki/StuckBeacon)
	"bintval 500"
	
	# Suppress SSID broadcasting
	# "hide_ssid 1"
)

# Set host_roaming to 2 before scanning and after scanning to 0
iwpriv_scan_pre_ath0="host_roaming 2"
iwpriv_scan_post_ath0="host_roaming 0"

Troubleshooting

If you get the error "Could not connect to kernel driver" (when trying to start hostapd) look in your hostapd.conf if you have enabled encryption because if you haven't, the interface isn't started correctly. For details, see the MadWifi ticket #552.

Installing from Source

If you have installed MadWifi from portage, you should remove it first:
emerge -aC madwifi-ng madwifi-ng-tools

For information on different methods of obtaining MadWifi, see the MadWifi wiki article Getting MadWifi.

If you choose to use Subversion, you will first need to install it with:
emerge -a subversion

For instructions on installing MadWifi from source, see the MadWifi First Time How To.

You can also install MadWifi from source. The difference is that you'll have the most current development version including all bug fixes. However, installing the latest development version from source is generally unsupported and may be unstable.

You should generally only install from source if you know that there is support or features currently missing from the current versions in portage that you need.

Preparation

You can skip this section if you have not installed MadWifi yet.

Shutdown the interface (if available):
/etc/init.d/net.ath0 stop

If the interface does not exist for you, do the following (repeat the lines for all MadWifi devices you have; ath1, etc.):

ifconfig ath0 down ifconfig wifi0 down
Unload the module:
rmmod ath_pci

Obtaining the source code

If you have installed MadWifi from portage, you should remove it first:
emerge -aC madwifi-ng madwifi-ng-tools
You need a SVN client to obtain the source code. If you choose to use Subversion, you will first need to install it with: emerge -a subversion. Then checkout the current branch to /usr/src/madwifi:
cd /usr/src/ && svn checkout http://svn.madwifi-project.org/madwifi/trunk/ madwifi

For further information on different methods of obtaining MadWifi, see the MadWifi wiki article Getting MadWifi. Updating the source code to the current version

If you have already compiled MadWifi from source, go to the subdirectory "scripts" of the source code and execute the following:

madwifi-unload && ./utils/find-madwifi-modules.sh $(uname -r)
Note: It is assumed that you have currently started the kernel in which you have installed the MadWifi modules.

To update to the current version of the source, type:

cd /usr/src/madwifi/ && svn update && make clean

Install

Now that you have the MadWifi code, you need to compile it. This can be done by typing:

make

This will install the driver by copying all of the modules, tools and man pages to the correct directories on your system:

make install

Now we will load the MadWifi driver module into the running system:

modprobe ath_pci

Notes

If you have any problems with building the MadWifi driver, please refer to "BuildProblems" on the MadWifi wiki. For further instructions on installing MadWifi from source, see the MadWifi First Time How To.

Troubleshooting

If you have any problems with building MadWifi, please first refer to "BuildProblems" on the MadWifi wiki.

Broken Regulatory Domain

Some Atheros-based cards (in particular D-Link models such as the DWL-AG530) have the regulatory domain set wrong. The domain set for these cards will work with the vendor-specific Windows drivers, but not with generic Atheros drivers such as madwifi.

To check your card's regulatory domain, type the following with MadWifi loaded, replacing "wifi0" by the device name:

sysctl dev.wifi0.regdomain

You should see output along the lines of:

dev.wifi0.regdomain = 18

If the regular domain is set to 18 (unknown, 0x12), you will need to fix it. Use these steps to patch the regdomain to 16 (FCC, 0x10): Make sure ath_pci is loaded: modprobe ath_pci

Run lspci to find the card's memory address:
lspci -v
Code: lspci -v
0000:00:0a.0 Ethernet controller: Atheros Communications, Inc. AR5212 802.11abg NIC (rev 01)
Subsystem: D-Link System Inc: Unknown device 3a14
Flags: bus master, medium devsel, latency 168, IRQ 169
Memory at ec100000 (32-bit, non-prefetchable) size=64K Capabilities: 44 Power Management version 2

The memory address shown above is 0xec100000.

Find the regdomain to set; 0x10 (16) is FCC.

Run the ath_info utility from MadWifi, replacing address by an address such as 0xec100000 and regdomain by the new regdomain, such as 0x10:
ath_info -w <address> regdomain <regdomain>

The tool will ask for confirmation. Double check the value, and confirm. Reload the module.

If you ever want to undo this change, just run the command again with the old regdomain value.

Channel hopping

If the card constantly changing channels and can not connect to any access point, try to lock it in the desired channel:
athchans -i ath0 6-6

See Also