Skip to content

Commit

Permalink
mac80211_hwsim: 802.11 radio simulator for mac80211
Browse files Browse the repository at this point in the history
mac80211_hwsim is a Linux kernel module that can be used to simulate
arbitrary number of IEEE 802.11 radios for mac80211 on a single
device. It can be used to test most of the mac80211 functionality and
user space tools (e.g., hostapd and wpa_supplicant) in a way that
matches very closely with the normal case of using real WLAN
hardware. From the mac80211 view point, mac80211_hwsim is yet another
hardware driver, i.e., no changes to mac80211 are needed to use this
testing tool.

Signed-off-by: Jouni Malinen <j@w1.fi>
Acked-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
  • Loading branch information
Jouni Malinen authored and John W. Linville committed Jun 14, 2008
1 parent 14a08a7 commit acc1e7a
Show file tree
Hide file tree
Showing 6 changed files with 637 additions and 0 deletions.
68 changes: 68 additions & 0 deletions Documentation/networking/mac80211_hwsim/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
mac80211_hwsim - software simulator of 802.11 radio(s) for mac80211
Copyright (c) 2008, Jouni Malinen <j@w1.fi>

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as
published by the Free Software Foundation.


Introduction

mac80211_hwsim is a Linux kernel module that can be used to simulate
arbitrary number of IEEE 802.11 radios for mac80211 on a single
device. It can be used to test most of the mac80211 functionality and
user space tools (e.g., hostapd and wpa_supplicant) in a way that
matches very closely with the normal case of using real WLAN
hardware. From the mac80211 view point, mac80211_hwsim is yet another
hardware driver, i.e., no changes to mac80211 are needed to use this
testing tool.

The main goal for mac80211_hwsim is to make it easier for developers
to test their code and work with new features to mac80211, hostapd,
and wpa_supplicant. The simulated radios do not have the limitations
of real hardware, so it is easy to generate an arbitrary test setup
and always reproduce the same setup for future tests. In addition,
since all radio operation is simulated, any channel can be used in
tests regardless of regulatory rules.

mac80211_hwsim kernel module has a parameter 'radios' that can be used
to select how many radios are simulates (default 2). This allows
configuration of both very simply setups (e.g., just a single access
point and a station) or large scale tests (multiple access points with
hundreds of stations).

mac80211_hwsim works by tracking the current channel of each virtual
radio and copying all transmitted frames to all other radios that are
currently enabled and on the same channel as the transmitting
radio. Software encryption in mac80211 is used so that the frames are
actually encrypted over the virtual air interface to allow more
complete testing of encryption.

A global monitoring netdev, hwsim#, is created independent of
mac80211. This interface can be used to monitor all transmitted frames
regardless of channel.


Simple example

This example shows how to use mac80211_hwsim to simulate two radios:
one to act as an access point and the other as a station that
associates with the AP. hostapd and wpa_supplicant are used to take
care of WPA2-PSK authentication. In addition, hostapd is also
processing access point side of association.

Please note that the current Linux kernel does not enable AP mode, so a
simple patch is needed to enable AP mode selection:
http://johannes.sipsolutions.net/patches/kernel/all/LATEST/006-allow-ap-vlan-modes.patch


# Build mac80211_hwsim as part of kernel configuration

# Load the module
modprobe mac80211_hwsim

# Run hostapd (AP) for wlan0
hostapd hostapd.conf

# Run wpa_supplicant (station) for wlan1
wpa_supplicant -Dwext -iwlan1 -c wpa_supplicant.conf
11 changes: 11 additions & 0 deletions Documentation/networking/mac80211_hwsim/hostapd.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
interface=wlan0
driver=nl80211

hw_mode=g
channel=1
ssid=mac80211 test

wpa=2
wpa_key_mgmt=WPA-PSK
wpa_pairwise=CCMP
wpa_passphrase=12345678
10 changes: 10 additions & 0 deletions Documentation/networking/mac80211_hwsim/wpa_supplicant.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
ctrl_interface=/var/run/wpa_supplicant

network={
ssid="mac80211 test"
psk="12345678"
key_mgmt=WPA-PSK
proto=WPA2
pairwise=CCMP
group=CCMP
}
13 changes: 13 additions & 0 deletions drivers/net/wireless/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,19 @@ config ADM8211

Thanks to Infineon-ADMtek for their support of this driver.

config MAC80211_HWSIM
tristate "Simulated radio testing tool for mac80211"
depends on MAC80211 && WLAN_80211
---help---
This driver is a developer testing tool that can be used to test
IEEE 802.11 networking stack (mac80211) functionality. This is not
needed for normal wireless LAN usage and is only for testing. See
Documentation/networking/mac80211_hwsim for more information on how
to use this tool.

To compile this driver as a module, choose M here: the module will be
called mac80211_hwsim. If unsure, say N.

source "drivers/net/wireless/p54/Kconfig"
source "drivers/net/wireless/ath5k/Kconfig"
source "drivers/net/wireless/iwlwifi/Kconfig"
Expand Down
2 changes: 2 additions & 0 deletions drivers/net/wireless/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,5 @@ obj-$(CONFIG_RT2X00) += rt2x00/
obj-$(CONFIG_P54_COMMON) += p54/

obj-$(CONFIG_ATH5K) += ath5k/

obj-$(CONFIG_MAC80211_HWSIM) += mac80211_hwsim.o
Loading

0 comments on commit acc1e7a

Please sign in to comment.