[Documentation] [TitleIndex] [WordIndex

linux_networking: access_point_control | asmach | asmach_tutorials | ddwrt_access_point | hostapd_access_point | ieee80211_channels | linksys_access_point | multi_interface_roam | network_control_tests | network_detector | network_monitor_udp | network_traffic_control | wpa_supplicant | wpa_supplicant_node

Package Summary

A ROS node that controls a hostapd-based access point. It is mainly intended for use with a wireless network adapter running in master mode. It implements the dynamic_reconfigure interface defined in the [[access_point_control]] package.


A ROS node for starting and controlling a hostapd-based access point. This node works with wifi adapters that have nl80211-compatible drivers which support master mode (see here for more information).



ap_hostapd_node.py provides control of a hostapd-based access point running on a Linux network interface in master mode.


Node parameters
These are the startup parameters of the node. ~interface (string) ~ip (string) ~netmask (string) ~hostapd_path (string, default: hostapd)
Dynamically Reconfigurable Parameters
Implements the dynamic_reconfigure interface defined in access_point_control. See the dynamic_reconfigure package for details on dynamically reconfigurable parameters. ~enabled (bool, default: False) ~ssid (str, default: test) ~wmm (bool, default: False) ~mode (str, default: b) ~freq (double, default: 2412000000.0) ~ieee80211n (bool, default: False) ~encryption_mode (string, default: open) ~encryption_pass (string) ~txpower_auto (bool, default: True) ~txpower (int, default: 0) ~bitrate (int, default: 0) ~status (string, default: OK) ~errmsg (string, default: )

Usage examples

Manual control

This is an example that shows how to set up an access point and control its parameters using the reconfigure_gui interface.

The following launch file starts an AP node on the wlan0 interface and the reconfigure_gui:

    <node name="ap_wlan0" pkg="hostapd_access_point" type="ap_hostapd_node.py">
        <param name="interface" value="wlan0"/>
        <param name="ip" value=""/>
        <param name="netmask" value=""/>
    <node name="reconfigure_node" pkg="dynamic_reconfigure" type="reconfigure_gui"/>

The following window will appear showing that initially the AP is not running (the enable checkbox is unchecked):


The desired configuration is selected: mode a, channel 44, WPA security with the chosen password, a TX power level of 8 dBm and a TX bitrate of 24Mbit/s. Next the enabled checkbox is checked at the AP is started:


Next, a channel in the 2.4GHz band is selected, which is illegal in 802.11a mode, thus an error message is displayed and the AP is stopped:


AP control from Python

The hostapd access point can be controlled programatically via the dynamic_reconfigure interface described above. The following snippet reproduces the manual interaction from the previous section.

import dynamic_reconfigure.client

ap = dynamic_reconfigure.client.Client("ap_wlan0")

freq = IEEE80211_Channels.get_freq(44, IEEE80211_Channels.BAND_5000_MHz)
config = ap.update_configuration({"enabled": True, "mode": 'a', "freq": freq, "encryption_mode": "wpa", "encryption_pass": "sample_password", "txpower_auto": False, "txpower": 8, "bitrate": 24*10**6})

if config['status'] != "OK":
    raise Exception("AP failed to start: " + config['errmsg'])

freq = IEEE80211_Channels.get_freq(1, IEEE80211_Channels.BAND_2400_MHz)
config = ap.update_configuration({"freq": freq})

if config['status'] != "OK":
    raise Exception("AP failed to start: " + config['errmsg'])

Command-line tools


This script is useful for setting up a mac80211_hwsim-based setup. mac80211_hwsim is a 802.11 radio simulator. The script takes two parameters:

If the mac80211_hwsim is not loaded or if the number of radios it has currently spawned is smaller than total number of radios then it is re-loaded with the proper radio count. The script prints to its output the name of the radio index-th interface.

For example (this is taken from a real setup), suppose that the system has a real wireless interface with name wlan1 and we need to spawn three virtual interfaces. Their names will be wlan0, wlan1 and wlan2.

Using find_hwsim_iface.py:

$ echo `rosrun hostapd_access_point find_hwsim_iface.py 1 3`
$ echo `rosrun hostapd_access_point find_hwsim_iface.py 2 3`
$ echo `rosrun hostapd_access_point find_hwsim_iface.py 3 3`

The script can be used to launch nodes on the n-th virtual interface with roslaunch. The following example, launches two nodes on the first and second mac80211_hwsim interfaces while ensuring that there are at least three total interfaces:

    <node name="ap1" pkg="hostapd_access_point" type="ap_hostapd_node.py">
        <param name="interface" command="$(find hostapd_access_point)/scripts/find_hwsim_iface.py 1 3"/>

    <node name="ap2" pkg="hostapd_access_point" type="ap_hostapd_node.py">
        <param name="interface" command="$(find hostapd_access_point)/scripts/find_hwsim_iface.py 2 3"/>


This script sets up NAT routes and ARP entries so that packets can be sent "over-the-air" between two interfaces connected to the same host. By default, packets addressed to the IP of a local interface get sent over the local route.

The script takes six parameters:

An example:

# rosrun hostapd_access_point hwsim_nat_setup.sh wlan0 wlan1

# ifconfig wlan0
wlan0     Link encap:Ethernet  HWaddr 02:00:00:00:00:00  
          inet addr:  Bcast:  Mask:

# ifconfig wlan1
wlan1     Link encap:Ethernet  HWaddr 02:00:00:00:01:00  
          inet addr:  Bcast:  Mask:

A packet with destination IP will travel "over-the-air" from wlan1 to wlan0, while packets with destination IP will travel from wlan0 to wlan1.

Known problems:

Tips and known bugs

2011-11-19 12:24