Tag Archives: wi-fi direct

Running the Distributed Mandelbrot app

This app (download from Google play) demonstrates sharing jobs on mobile devices using Wi-Fi Direct. This is a prototype developed as proof-of-concept for the Honeybee model for my PhD dissertation. In this app, we generate the Mandelbrot set, with the aid of multiple mobile devices.

Delegator & workers:
The device that offloads work to other devices is referred to as the delegator, and the devices that take on work are referred to as the workers.

Step 01:
Since Wi-Fi Direct is still relatively new, some implementations are somewhat unpredictable. Therefore, I would recommend that the devices be ‘primed’ to use Wi-Fi Direct (especially the p2p group formation) before you run the app. Here’s what to do:

  1. Disconnect from any Wi-Fi network that the device is connected to. A live Wi-Fi connection can sometimes interfere with Wi-Fi Direct transmission. Keep Wi-Fi ‘on’, but ‘forget’ any networks that the device automatically connects to.wifiDisc
  2. Switch on Wi-Fi Direct.                                       wifidon
  3. In this example, we will use 3 devices. The device ‘Android_1’ will be the delegator, and the other 2 will be workers. We will now manually pair the devices and create a Wi-Fi p2p group, where the delegator is the p2p Group Owner (GO). The delegator needs to be the GO as only the GO can ‘see’ and connect to other devices. In the app, this is done programmatically. However, for some devices, things run smoother if the process is manually done first.
  4. Click ‘Search for devices’ on all 3.                       wifidSearchall
  5. Use Android_1 to connect to the other 2 devices.                                  connect3
  6. Done! Now disconnect the 2 devices before running the app. discon1


Step 02:
Now the app is ready to run. Run it on all three devices. Select option ‘Look for work’ on the workers (Android 2 & Android 3 in this example). Select ‘Share my work with others’ on the delegator (Android_1), and type the number of ‘iterations’ for the Mandelbrot algorithm. The higher the number of iterations are, the more resource intense the task becomes.


Step 03:
Click ‘Look for work’ on the worker devices.


Step 04:
Click ‘Look for other devices’ on the delegator device. This will start the resource discovery on the delegator and soon, the worker devices will be displayed as a list. Click on each entry on the list to connect to each worker.



Step 05:

The delegator would have already started executing jobs in Step 04, in parallel to its resource discovery procedure. Workers start executing jobs as soon as they connect. Although this is not visible on the app, you can see this taking place in the logcat output in the ADT if you connect the devices to a computer through USB.

Some useful log cat tags 
There are several debug tags in the program, that can be used to monitor the program execution. Some of these are as follows:

Jobs done: use on the delegator device. Shows the number of jobs done so far.
Queenbee: use on the delegator device. Shows the end result after the task completes. This outputs the total program time, battery level and no. of jobs done by each device.
RANDOM: use on the delegator device. Shows the heartbeats of the worker devices connected. If a timestamp==null becomes false, this signifies a worker has disconnected. The delegator will add the said worker’s jobs back to the job pool in this case.

Screen Shot 2014-08-19 at 2.36.21 PM

A screenshot of the Logcat output using the ADT plug-in in Eclipse.

Some experiments to try out:

  • Disconnect one or more workers while they are working.
  • Try out the continuous resource discovery by introducing workers at random intervals.
  • Increase\decrease the iteration count.
  • Use heterogenous devices (in terms of computation capability). Which device combinations give the most speedup?

Step 06:

the delegator will display the generated Mandelbrot image upon task completion. Some program stats will also be shown. Exit the program and start again if you want to do more experiments.