title: Simulating WiFi device in android emulator with mac80211_hwsim kernel module
body: <p>I am looking to simulate an additional WiFi device in a rooted android emulator (to simulate a device my company makes). So far I have found the linux kernel module, <code>mac80211_hwsim</code>, which seems like it would help me create virtual networks like this. I believe this is also the mechanism that the emulator uses to create its fake wifi network already. I have found <code>/vendor/bin/mac80211_create_radios</code> which seems to allow me to access that module (to create more channels / radios which appear in <code>ip link show</code> as <code>wlan*</code>).</p>
  <p>If this is in fact the right way forward, once I create some more channels for that kernel module, I want to be able to connect to a program on my local computer after connected to this other WiFi network (similar to how <code>10.0.2.2</code> maps to the host computer). (<a href="https://developer.android.com/studio/run/emulator-networking" rel="nofollow noreferrer">this looks helpful</a> with the <code>redir</code> command)</p>
  <p>Does this sound reasonable and does anyone have some tips going forward? It's been challenging to find information that is relevant to Android in this area.</p>
  <p>Some relevant files for how I believe the emulator does this:</p>
  <ul>
  <li><code>/vendor/bin/init.wifi.sh</code></li>
  <li><code>/vendor/bin/init.ranchu-net.sh</code></li>
  <li><code>/vendor/bin/mac80211_create_radios</code></li>
  <li><code>/vendor/etc/simulated_hostapd.conf</code></li>
  </ul>