Boost WIFI Speed by Forcing 40 MHz Channels in hostapd on RPi

802.11n can double the channel bandwidth of 802.11g from 20 MHz to 40 MHz, but this operation mode is not recommended in areas that the spectrums are congested and likely interfere with existing WIFI and bluetooth devices. As a result, hostapd will not enable 40 MHz when it finds other channels are being used, like what is seen from the hostapd log below:

However, this is unrealistic in modern cities. You should be grateful the primary channel you choose has not been used already, let alone the additional one for 40 MHz. What can we do? We have to force hostapd to turn on 40 MHz anyway. But since hostapd does not have any configuration options for that, we have to recompile hostapd from source. Actually, this has been done in other distros. For example, OpenWRT and Arch has patched their hostapd with the noscan patch, which adds an option to force 40MHz mode regardless of the environment.

Before turning on 40 MHz, the iwconfig on my laptop is like this, notice the bit rate is only 54 Mb/s:

Now let us start. First you need to add a deb-src source to apt so that we can download source packages. Note that I am still using Raspbian Wheezy. If you use Jessie, change the deb-src line according to your original deb line.

Save the following patch into a file:

Because we are going to create a new hostapd package, it’d be a good practice to increment the version number by adding a new section at the top of debian/changelog, like this:

Now we are ready to compile the packages:

If it succeeds, install the new package with dpkg -i.

Restart hostapd, it should now force 40 MHz mode:

And my iwconfig output now shows Bit Rate is 150 Mb/s, yay!

2 thoughts on “Boost WIFI Speed by Forcing 40 MHz Channels in hostapd on RPi”

  1. Is there any option for Pi3 and integrated wifi? I’m trying by editing hostapd to change channel width to 40MHz but it doesn’t seem to work…

  2. hi i am trying to use hostapd for wifi access point creation with the aim of getting aroung 500 Mbps speed ,my wifi card support maximun of 800 Mbps

    below are working conf file with hw_mode=g but i am gettimg maximim of 24 Mbps if i change hw_mode=a and channel = a hostapd failed to start any idea to make hostapd to work for maximim throughput i am using inter wifi card

    interface=wlp5s0
    #bridge=br0
    country_code=IN
    driver=nl80211
    ssid=GaianCOD
    ieee80211d=1
    ieee80211h=1
    ieee80211n=1
    hw_mode=g
    ht_capab=[HT40-][HT40+][SHORT-GI-40][DSSS_CCK-40]
    channel=6
    macaddr_acl=0
    auth_algs=1
    #ignore_broadcast_ssid=0
    wpa=2
    wpa_passphrase=123456789
    wpa_key_mgmt=WPA-PSK
    wpa_pairwise=TKIP
    rsn_pairwise=CCMP

Leave a Reply

Your email address will not be published.


2 × two =