Skip to content. | Skip to navigation

Personal tools

Navigation

You are here: Home / Wiki / PhantomNet / Facebook status update tutorial using PhantomNet portal

Facebook status update tutorial using PhantomNet portal

Overview


This tutorial will walk you through the steps to build and install test Android applications that control a Facebook application to do certain tasks programmably. 

In particular, Alice uploads a photo to Facebook every 3 minutes for 10 times and Bob (a friend of Alice on Facebook) continuously updates for the photos. We measure the time to complete a post and the time for a photo to be fetched from Facebook servers.

This functionality might be useful for users who want to understand how real applications function under various network conditions, or how mobile network protocol changes impact a smartphone application.  

This tutorial will be done in the PhantomNet (https://www.phantomnet.org) testbed via PhantomNet portal and geni-lib, using two Nexus 7 tablets attached to an Ip.access E-40 small cell and a OPEN EPC core network instant.

Git repository 


The tutorial is packaged in a Git repository. Clone the repository:

git clone git@gitlab.flux.utah.edu:binh/android-sdk-facebook.git && cd android-sdk-facebook

The cloned folder consists of 3 sub-folders:

  • apk: includes Facebook apks and scripts to re-sign the apk. 
  • scripts: includes the scripts for the tutorial.
  • test-blackbox: includes Java source code of the test applications. 

 

Create a profile and initiate an experiment using PhantomNet portal and Geni-lib


1. Topology overview:

Figure 1 shows the topology of the experiment in PhantomNet. 

In the radio side of the network, two Nexus 7 tablets running Android 4.4.2 are attached to a Ip.Access (E-40) LTE small cell base station via LTE. 

In the core side of the network, an OpenEPC instance consists of EPC components needed for a LTE/ECP network (i.e, SGW, MME, PGW, HSS). PGW is the gateway connecting the core network to the Internet (and Facebook servers). 

Figure 1. Tutorial topology

2. Create experiment profile in PhantomNet portal using Geni-lib:

PhantomNet allows users to create a profile that specifies topology, parameters, and set up scripts. After having a profile, multiple experiements could be initiated using the profile, each experiment will be an instance of the profile. In this tutorial, we will create a profile using Geni-lib source code in PhantomNet portal.

Step 1: Go to PhantomNet website at https://phantomnet.org and log in.

Step 2: In your personal homepage, create a profile by select "Create Profile" under "Actions".

 

 step 3: Assign a name for your profile. Then click on "Source" next to "Topology" button to specify the profile using a Geni-lib script.

 

step 4: Upload a Geni-lib Python script to specify the topology of the profile. Here is the geni-lib script that specifies the topology for our tutorial. Copy and paste the geni-lib script and click "Upload". Click "Accept" to finish uploading.

step 5: After uploading the geni-lib script, an Rspec will be generated for your profile. The Rspec specifies the resources (e.g., nodes, links) in an XML format. To see how the RSpec looks like, click on "XML" button in the "Create Profile" page (note that the XML is read-only, if you want to modify the topology, you would need to modify the geni-lib script). 

 

2. Instantiate an experiment in PhantomNet using the created profile:

Now as you created a profile that specifies the tology for your experiment, you can instantiate an experiment using the profile:

Step 1: To select the profile you have created, click on "Actions"->"My Profiles"Click on the profile that you created.

 

Step 2: Instatiate an experiment by click on "Instantiate" button. Click "Next" in the Select Profile page. Click "Next" in the Paramiterize page. Put a name for your experiment in the Finalize page and then click "Finish".

 

Step 3: After clicking "Finish" it might take up to 10 minutes for your experiment to be created and ready. You can see your experiment being instantiated on the flight. Once the experiment is ready, click on "List View" for ssh information of how to access your nodes.

 

 

Resign the Facebook apk


In order to let other apks control the Facebook apk, we need to resign the Facebook apk using a development key. We use zipalign to sign the Facebook application. On your computer install "zipalign" by:

sudo apt-get install zipalign

In this tutorial we use Facebook 25.0.0.19.30. The original apk could be found in apk/Facebook- 25.0.0.19.30.apk 

Since we need to control the Facebook apk without knowing the source code of it, we need to re-sign the apk using a debugger key. While you can use any key to re-sign the apk, we will use Android's default debugger key that comes with the standard SDK to sign the apk: 

bash apk/signapk.sh apk/Facebook-25.0.0.19.30.apk apk/debug.keystore android androiddebugkey

After this step, a re-signed apk will be created in the apk folder named apk/signed_Facebook- 25.0.0.19.30.apk. We’ll use this apk throughout this tutorial. 

 

Install the resigned Facebook apk to the Nexus 5 devices:


We need to install the resigned Facebook apk  to the 2 Nexus 5. We will use "adb" interface to do this.

First, we tell PhantomNet to connect to ADB daemon on the Nexus 5 via a special ADB target by:

$> pnadb -a

 

List the available devices in the experiment by:

$> adb devices
List of devices attached 
0fabdc5e device
1fab7f8a device

Install the apk to the devices using the device IDs above: 

adb -s 0fabdc5e install apk/signed_Facebook-25.0.0.19.30.apk
adb -s 1fab7f8a install apk/signed_Facebook-25.0.0.19.30.apk

 

The test applications 


We need two test applications for Alice and Bob that launch and control Facebook apk to do predefined tasks: Alice uploads a photo to Facebook and Bob continuously fetches the photo. 

The two applications are Android test applications and their apk could be found in apk/alice.apk and apk/bob.apk.

Note: If you would like to see how the apks were implemented, please refer to test-blackbox folder. In short, Alice opens the Facebook apk, touches on update status button and post a photo every 3 minutes for 10 times; Bob opens Facebook apk, scrolls down the main feed screen to fetch new updates from Alice. 

During execution, Alice measures the time to post a photo (i.e, the elapsed time between touching the post button and the moment the progress bar disappears); Bob records the moment that photo appears on Bob’s main feed. The fetching time is the elapsed time between the moment the photo was posted by Alice and the moment it appears on Bob’s screen. 

The source code for Alice and Bob apk are in "/test-blackbox/alice/src/com/testAlice/" and "/test-blackbox/bob/src/com/testBob/".

 

Install Alice and Bob apk applications to the Nexus 5 devices:


We need two test applications for Alice and Bob that launch and control Facebook apk to do predefined tasks: Alice uploads a photo to Facebook and Bob continuously fetches the photo. 

The two applications are Android test applications and their apk could be found in apk/alice.apk and apk/bob.apk. To install the two applications:

adb -s 0fabdc5e install apk/alice.apk
adb -s 1fab7f8a install apk/bob.apk

 

Sign up for Facebook accounts and log-in manually:


The tutorial assumes you already logged into the Facebook accounts on the Nexus 5 devices so that the scripts will post Facebook status automatically without the log-in actions. Therefore, you will need to create 2 Facebook accounts manually (e.g., using your own computer and the Facebook website). The accounts could have any name as you wish. After having the account, log-in to Facebook accounts on the Nexus devices. A way to log-in to Facebook is via a GUI interaction with the devices using Culebra. A tutorial of how to use Culebra to interact with Nexus 5 via GUI is here.

 

Run the test applications and observe:


Finally, we need to run the Alice and Bob Apps. The apps will execute the auto-post and auto-fetch actions on Facebook. There is a script to wakeup and unlock the devices and launch the Alice and Bob apks:

bash scripts/alice-bob.sh

During the execution of this script, if you have a Culebra GUI window open, you will see the Alice and Bob apks control the Facebook apk to post/fetch status.

 

Gathering results 


After running the test applications, two log files are created inside the scripts folder: scripts/alice.logcat and scripts/bob.logcatalice.logcat records the moment Alice clicks on the post status button and the moment the photo is posted. bob.logcat records the moment the photo appears on Bob’s screen. Note that each photo is posted with a unique hash text that is used to distinguish them to calculate elapsed time. You can open the logcat files (i.e., using "adb shell") and calculate the elapsed time yourself or use the following script: 

bash scripts/process_delta_time.sh

The output of this script is status|post time|fetch time, where post time is the elapsed time to post a photo on Alice in millisecond and fetch time is the time for Bob to fetch the photo in millisecond. 

 

Conclusions


This tutorial showed you the steps to run test applications to control Facebook apk and observe the interactions between Facebook and a LTE/EPC network. Similarly, you can build your own test applications to control other apk such as Youtube, Twitter to understand how the apps interact with the LTE/EPC network or how the LTE/EPC network performance could affect the apps.