Android technical articles

Android IBSS


Ad-Hoc (IBSS) mode support for Android 4.2.2 / 4.3 / 4.4 / 5.0


This page provides information about the status of integrated Ad-Hoc (IBSS) mode support in Android and documents our development effort.

We have created patches to bring the missing Ad-Hoc (IBSS) mode to Android, in a way that is fully integrated into the Android system API and user-interface. Using them, we are able to create and connect to Ad-Hoc networks from the standard user interface (Settings - WiFi) and Applications have an API to configure their "own" Ad-Hoc network (allthough tru reflection until the changes are officially accepted in AOSP). We believe this will help people who need more capabilities than WiFi Direct (also read this article on the limits of WifiDirect) and that this can extend diverse usages of Android mobile devices.

In more detail, we have modified the WLAN driver "bcmdhd", extended the Android framework, the public Android API and added the missing parts to the "Settings" application. We are only testing Nexus S, Galaxy Nexus and Nexus 7 devices, but a few more devices are supported in CyanogenMod. Once a device kernel WiFi driver supports Ad-Hoc mode, the UI will automatically show Ad-Hoc mode options.

We originally based our additions on CyanogenMod 10.1-M2 (Android 4.2.2 JDQ39) and Google AOSP Android 4.2.2 and have submitted all changes upstream. While our changes still have not been accepted in the official Google AOSP (with little feedback or explanations), they got merged into CyanogenMod from version 10.1.0 onwards and we continue to forward-port the changes to newer CyanogenMod and AOSP versions. The easiest way to get Android with Ad-Hoc mode support is to just install CyanogenMod.


21.01.2015: Ported to CyanogenMod 12: Our IBSS changes got forward ported to CyanogenMod 12 which is based on Android 5.0 "Lollipop". Nexus 7 is working fine, but CM-12 support for the older devices like Galaxy Nexus and Nexus S is still missing and may not be added (not sure, check the nightly builds).

13.03.2014: Ported to CyanogenMod 11: We just ported the UI changes to CyanogenMod 11 (CM-11), which got lost in the CyanogenMod rebase to Android 4.4. See the change here in CyanogenMod gerrit. It got merged and became part of the nightly build on 16.03. Also we rebased the changes for AOSP 4.4 and submitted to Google again (part1 and part2).

14.05.2013: New App to setup Ad-hoc networks thru reflection: We have updated the demo application for setting up Ad-hoc networks. It can now be built externally and installed on any device, as we are accessing the new methods thru Java reflection.

17.04.2013: Samsung Epic 4G kernel gets IBSS mode support in CyanogenMod. One more device :)

23.04.2013: Workaround for video queue problems on BCM4330: The BCM4330 chipset has problems in IBSS mode when packets are sent into the WME video queue (AC_VI). This affects all packets which have their DSCP priority set to 4 or 5 (TOS 0x80 and 0xa0) and the symptom is that these packets get lost, instead we see excessive RTS/CTS and sometimes this leads to a complete hang of the chip. Since the problem happens in firmware we can not do much except adding a simple workaround to downgrade the "video" priority to "best effort" (patch).

15.04.2013: CyanogenMod merged IBSS support for Nexus S, Galaxy Nexus and Nexus 7. Finally the IBSS support has been merged in the kernel of these devices and is available in CyanogenMod nightly builds. Also Channel/Frequency selection has been merged. So now the easiest way to get IBSS support is to use the nightly images from

28.03.2013: Added Channel/frequency selection to Settings for newly created Ad-Hoc networks. We provide new images which include these changes below. The new images also include the iw command line utility for debugging.

25.03.2013: CyanogenMod merged IBSS support for Samsung Galaxy S, Samsung Captivate, Samsung Vibrant and Samsung Fascinate,which makes these devices the first to actually get IBSS mode support thru the official CyanogenMod nightly build. ( 

24.03.2013: Framework merged in CyanogenMod: The changes to the framework got merged in CyanogenMod and are already part of the nightly builds! Still missing are the kernel changes. But this means you don't have to build the entire Android tree to try IBSS mode on another device - you can download the latest nightly build and then only patch and build the kernel for your device. Let us know if you succed on any device not mentioned here!

Download and usage

We repeat, nowadays the easiest way to get Ad-Hoc mode support is to download CyanogenMod for the supported devices. For reference we provide our original CyanogenMod 10.1-M2 based system images which you can install as usual (using ClockworkMod recovery, and "install zip from sdcard") if you want to try our IBSS mode changes:

The following devices have Ad-hoc mode support thru CyanogenMod, which you can download from

  • Samsung Galaxy S, Samsung Captivate, Samsung Vibrant and Samsung Fascinate ("aries")
  • Nexus 7 ("grouper")
  • Galaxy Nexus ("maguro")
  • Nexus S ("crespo")
  • Samsung Epig 4G ("epicmtd")

After installation, you can see existing Ad-Hoc networks in the list of networks in Settings - Wi-Fi. This screenshot shows this and that we are already connected to an Ad-Hoc network:

You can also create a new Ad-Hoc network using the "+" (Add) button. The "Ad-Hoc (IBSS) Network" option is hidden under "Show advanced options":

Screenshot Adhoc-Add2

Showing existing Ad-Hoc network connection details:

Screenshot Adhoc-Connect2

Another way to use the new features is to try the AdhocConfigDemo App below, or use similar code in your own App to automatically configure your own Ad-Hoc network.

Building and patches


Building based on CyanogenMod 10.1-M2

We built our images based on CyanogenMod 10.1-M2. Please follow the CyanogenMod instructions for checking out the sources and building.To use the M2 tag check out using the following repo commands:

repo init -u git:// -b cm-10.1
repo init -m cm-10.1-M2.xml
repo sync

You can also use the latest cm-10.1 branch of CyanogenMod (not M2) but then you will need to check yourself which of our changes are already included and which are not.

After you have synced all sources and before applying the patches, you need to run the breakfast command to download the kernel sources. Then you can optionally initiate new branches:

repo start IBSS external/wpa_supplicant_8 frameworks/base packages/apps/Settings

And depending on which kernels you are building:

repo start IBSS kernel/asus/grouper kernel/samsung/tuna kernel/samsung/crespo

Here is a patch that includes all changes: IBSS-all-in-one.diff (includes all patches below) - you can apply it at the top CyanogenMod directory.

patch -p1 < IBSS-all-in-one.diff

Otherwise you can apply all separate patches by going into the respective subdirectories and typing "git am patchname", or better by pulling them from the CyanogenMod Gerrit by using the commands from the links below, for example:

git pull refs/changes/35/34635/1

The kernel patches are all essentially the same, with just line number changes. If you are building for another device which has a Broadcom chipset, you can try to apply it to your kernel tree, for example:

cd kernel/acer/t30
patch -p1 < kernel-asus-grouper-0001-bcmdhd-Enable-Ad-Hoc-IBSS-mode.patch

Using CyanogenMod nightly builds

Since the changes have been included into CyanogenMod, the system is ready for Ad-Hoc mode, but the options will only be shown if the kernel driver supports IBSS mode. See the list above to see which devices come with Ad-Hoc mode support by default.

If your device is not yet supported but has a Broadcom chipset and uses the "bcmdhd" driver, chances are that you can apply one of the kernel patches listed above (e.g. this one). You then re-compile the kernel, create a boot.img and boot into it. Inside the CyanogenMod tree this works like this:

make bootimage
adb reboot bootloader
fastboot boot out/target/product/grouper/boot.img

Note that unfortunately there are many different "bcmdhd" driver versions in different device trees, and one some the patch alone is not enough.


Below we provide the links to the changes in CyanogenMod and AOSP Gerrit and "upstream" if available. Please note that the patches submitted to CyanogenMod do NOT change the public API, as this is not allowed by CM policy, but the local ones and the ones submitted to AOSP do, since we want to change the public API in the long run.

Local patch
CyanogenMod Gerrit AOSP Gerrit Upstream


33720 (merged) 53582 merged hostap
external-wpa_supplicant_8-0002-Add-capability-flag...patch 33721 (merged) 53583 merged hostap
frameworks-base-0001-Wifi-Enable-Ad-Hoc-IBSS-net...patch 33722 (merged) 53580 AOSP
frameworks-base-0002-Wifi-Add-IBSS-supported-method.patch 33723 (merged) 53581 AOSP
packages-apps-Settings-0001-Wifi-Allow-configuration-of-Ad-H...patch 33727 (merged) 53584 AOSP
packages-apps-Settings-0002-Wifi-Enable-IBSS-options-only-if...patch 33728 (merged) 53585 AOSP
kernel-samsung-tuna-0001-bcmdhd-Enable-Ad-Hoc-IBSS-mode.patch 33726 (merged) n/a  
kernel-samsung-crespo-0001-bcmdhd-Enable-Ad-Hoc-IBSS-m...patch 33725 (merged) n/a  
kernel-asus-grouper-0001-bcmdhd-Enable-Ad-Hoc-IBSS-mode.patch 33724 (merged) n/a  
external-wpa_supplicant_8-0003-Include-frequencies-in-get_ca...patch 34633 (merged) n/a submitted hostap
frameworks-base-0003-Wifi-Get-the-list-of-supported-channels.patch 34634 (merged) 54793 AOSP
packages-apps-Settings-0003-Wifi-Add-frequency-selection-fo...patch 34635 (merged) 54794 AOSP
kernel-samsung-tuna-0002-bcmdhd-workaround-broken-AC-video...patch 36383 n/a  
kernel-asus-grouper-0002-bcmdhd-workaround-broken-AC-video...patch 36382    

Technical Details

Kernel driver

Obviously support for IBSS mode is something that has to come from the kernel WLAN driver in the first place. We have enabled IBSS mode in the "bcmdhd" driver which is the driver for many Broadcom chipsets. Luckily most of the functionality is already there and we just have to enable Ad-Hoc mode. The most important part of the patch is therefore already well known to the community:

+++ b/drivers/net/wireless/bcmdhd/wl_cfg80211.c

The rest is just dealing with statistics gathering to show signal strength in the status bar. Here are the patches for grouper (Nexus 7), tuna (Galaxy Nexus) and crespo (Nexus S). They are all essentially the same and just may have different line numbers.

Broadcom is not the only chipset used by Android devices, but we are concentrating on it because most of the Nexus line devices have a Broadcom chipset and use the same "bcmdhd" driver. The devices we have tested so far are:

Device Chipset Bands driver driver version Status
Nexus 7 BCM4330 b/g/n (2GHz) bcmdhd Merged CyanogenMod, tested by Thinktube
Galaxy Nexus BCM4330 a/b/g/n (2GHz, 5GHz) bcmdhd Merged CyanogenMod, tested by Thinktube
Nexus S BCM4329 b/g/n (2GHz) bcmdhd Merged CyanogenMod, tested by Thinktube

Samsung Galaxy S, Samsung Captivate,
Samsung Vibrant, Samsung Fascinate

BCM4329 b/g/n (2GHz)? bcmdhd Merged CyanogenMod, User confirmed

Support for other kernels and other drivers may be added by fixing the driver and setting the same interface flag - if you do so, please let us know.


Android uses wpa_supplicant to manage the wireless network connections. wpa_supplicant can also be used to connect to or create Ad-Hoc networks.

We have had to add three minor modifications to wpa_supplicant, one to remember the frequency for newly created IBSS networks (PATCH1) and another to ask wether the driver supports IBSS mode (PATCH2) at runtime, so the User-Interface can dynamically show IBSS options only when the driver supports it. And a third one to get the list of available frequencies (PATCH3).

Note that contrary to common believe we have found that AP_SCAN=2 is not necessary, at least for the drivers above.

Android framework and API

The next part was to add the necessary bits to the Android framework, which is mostly passing the necessary configuration (mode and frequency) to wpa_supplicant and asking wpa_supplicant wether the driver supports IBSS mode. We are trying to push these API changes thru AOSP.

We have added the following to the public Android API:

  1. WifiConfiguration
        public boolean isIBSS;
        public int frequency;

Which represent the respecive configuration options (PATCH1).

  1. WifiManager
        public boolean isIbssSupported();
        public List<WifiChannel> getSupportedChannels();

Which can be used to ask wether the driver supports IBSS mode (PATCH2) and to get the list of available frequencies (PATCH3).

Note that we can only expect a valid result after WifiManager.WIFI_STATE_ENABLED has been reached. This is due to the internal state machine handling in WifiStateMachine: we can not expect wpa_supplicant to be running or drivers loaded at all times.

Android Settings App

Using these modifications to the framework we extended the standard "Settings" App to let us connect to and create Ad-Hoc networks as shown in the screenshots above. Also here our modifiation has three parts:

  • Add IBSS mode options in the GUI (PATCH1)
  • Enable them only when IBSS mode is supported by the driver (PATCH2),
  • Allow frequency selection for new IBSS networks (PATCH3)

Configuring Ad-Hoc mode from your own App

Using our changes we can configure Ad-Hoc networks from Applications, but the problem is that the API is not (yet?) official, so we have to use Java reflection to access the new fields. We also have to use the same method to configure static IP addresses, since there is no public API for that as well.

Here is the relevant part of the source code:

    /* We use WifiConfigurationNew which provides a way to access
     * the Ad-hoc mode and static IP configuration options which are
     * not part of the standard API yet */
    WifiConfigurationNew wifiConfig = new WifiConfigurationNew();

    /* Set the SSID and security as normal */
    wifiConfig.SSID = "\"AdHocDemo\"";

    /* Use reflection until API is official */

    /* Use reflection to configure static IP addresses */
    wifiConfig.setIpAddress(InetAddress.getByName(""), 24);

    /* Add, enable and save network as normal */
    int id = mWifiManager.addNetwork(wifiConfig);
    if (id < 0) {
        log("Failed to add Ad-hoc network");
    } else {
         mWifiManager.enableNetwork(id, true);

WifiConfigurationNew provides an interface to the new config options which internally uses reflection:

   private Class<?> wc;    public WifiConfigurationNew() {
        wc = this.getClass();

    public void setIsIBSS(boolean val) throws NoSuchFieldException, IllegalArgumentException,
            IllegalAccessException {
        Field fIsIBSS = wc.getField("isIBSS");
        fIsIBSS.set(this, val);

    public void setFrequency(int freq) throws NoSuchFieldException, IllegalArgumentException,
            IllegalAccessException {
        Field fFreq = wc.getField("frequency");
        fFreq.set(this, freq);

We can only check for IBSS support after WifiManager.WIFI_STATE_ENABLED has been reached, and therefore we have to register a BroadcastReceiver to catch the state change to it, and do the configuration after that, when we know that Wifi is enabled. See the source code below for details.

After running this App you can check in Settings -> Wi-Fi that an "AdHocDemo" network has been configured with a static IP address.

Download APK and Source code.


There are still many possible improvments and a lot of work to be done to support a wider variety of devices.

  • Test IBSS RSN
  • Add kernels and devices

Please let us know if you manage to patch the kernel and build for other devices than the ones mentioned above!

History, Background and References

Missing Ad-Hoc mode in Android has been a major obstacle to more innovative modes of networking with Android devices, from direct file-transfer between two devices without an AccessPoint, to Mesh networking and disaster operation (one example is the Serval Project). This is a real pity because with the networking and processing capabilities of modern smartphones, the original Mesh networking idea of many interconnected mobile devices forming networks in an "adhoc" way, comes so much closer.

The community requests for Ad-Hoc mode have been ignored for many years (bug 82, discussion), and so far there have been a few different attempts to make use of Ad-Hoc mode with Android. Most of these attempts try to add Ad-Hoc mode by installing a single App, but they require the device to be "rooted", and use the externally compiled and long deprecated "iwconfig" utility (WEXT). This limits their possibilities and therefore usefulness. We believe that it's better to move forward, extend the API and push Google to include it in AOSP. That's what we are trying here.

Nevertheless all these attempts show that there is a need for Ad-Hoc mode, and that the advertised Wifi Direct (P2P) can not always serve as a replacement for Ad-Hoc mode. To mention a few:

Also we have not been the first to do this, there was a similar attempt in 2010 (AOSP Gerrit 13291 and 13292) which was rejected due to an "ongoing internal ad hoc implementation that will conflict with this patch". So far this implementation has not surfaced, and the implementation in the Android version today is a bit different, but this patch has served us as a first hint where to look at.

Also there is another similar change in the AOSP review process: AOSP Gerrit 43070.

We want to show here that it is possible to add Ad-Hoc mode to the Android framework and we would like to join forces with all groups interested in this. Finally, our hope is that this IBSS mode changes can be integrated into the standard Android API in future versions, so at least the drivers which support IBSS mode can make use of it.


Please send us feedback and support the inclusion of IBSS mode in Android by making your voice heard in the Android bugtracker or groups.
Contact us with technical questions and comments.

Contact: Bruno Randolf (Thinktube Inc.)

Last update: 16 March 2014