hostapd is an application used to setup your wireless interface as an access-point (master mode). Hostapd requires a configuration file in order to operate, and in addition, it needs to support the driver used for the wireless interface. The testbed are running a custom compiled version of hostapd with the madwifi driver compiled into it.
To use hostapd, you have two choices.
- use hostapd as a global service
- use hostapd as a standalone user application
If you install hostapd through yum (Fedoras package system), it comes with some startup scripts located in /etc/init.d. To use the service, you have to create a configuration file, put it in /etc/hostapd/hostapd.conf and issue the service hostapd start|restart|stop command.
The nodes in the testbed are not configured to use hostapd as a global service. This because of the configuration complexity when running different tests and several users wanting to have their own configuration for their experiments. See the next section where running hostapd as a standalone application is explained.
Standalone User Application (Preferred)
This is the preferred method of running hostapd in the testbed. This allows you to tailor hostapd for your experiments and set the configuration to your preferences. But as you most of the time would use nearly identical configurations, you may create a configuration file which you use for several experiments.
When you have your hostapd.conf file configured (see below for an example configuration), you can start the application using the following command
# hostapd /path/to/file/hostapd.conf
hostapd will then run as a terminal application and print some debugging and status information to the screen. To stop the application, use CTRL+C.
As you probably don't want to run the application as a terminal application, you can run the application as a daemon by running the following command
# hostapd -B /path/to/file/hostapd.conf
hostapd will then detach from the shell and run as a background daemon (notice the -B parameter)
To be able to easily stop the daemon, you will want it to write its own process id (pid) to a file so you can kill it when you're done with your tests. To do this, you have to tell it where to save the .pid file. To do this, run the following command
# hostapd -B -P/path/to/pid/hostapd.pid /path/to/file/hostapd.conf
hostapd will now start, fork to the background and write its own process id to the file '/path/to/pid/hostapd.pid'. If you look at the contents of the .pid file, you'll see that the process id of the running application is written to it:
# cat /path/to/pid/hostapd.pid 2538
To stop the daemon, you can issue the kill command with the contents of the .pid file as a parameter like this:
# kill `cat /path/to/pid/hostapd.pid`
hostapd will then be killed, and the .pid file will be deleted.
To check if your hostapd daemon is running, you may issue the following command on the node it is running on
# ps aux | grep hostapd root 2538 0.0 0.0 39936 688 ? Ss 00:22 0:00 hostapd -P/path/to/pid/hostapd.pid -B /path/to/file/hostapd.conf
and you'll then see the running process. Notice the pid of the process (2538) is the same as hostapd has written to the .pid file
For running a WPA-PSK access-point one may use a configuration file like the one below
# hostapd_example1.conf interface=wlan0 driver=madwifi ssid=example channel=1 hw_mode=g channel=1 macaddr_acl=0 auth_algs=1 ignore_broadcast_ssid=0 wpa=3 wpa_passphrase=example_password wpa_key_mgmt=WPA-PSK wpa_pairwise=TKIP
From the example configuration above, you are running an access-point using the interface wlan0 on channel 1 (2412Ghz). The SSID of the access-point is example and the password/passphrase is example_password. You are also running the accesspoint in 802.11g mode and are using the madwifi driver. Setting macaddr_acl to 0 means that you don't want to filter clients on mac-address. To see a wpa_supplicant configuration which will work with this example configuration, see this page.
Please update this section with problems and issues you encounter when using hostapd
I have noticed that hostapd does not always seems to be able to set the correct channel on the interface. To circumvent this, you should set the channel of the interface before you start hostapd