Tomorrow we will be demonstrating an early prototype of Zygote (only the working title) at CamJam, the Cambridge based Raspberry Jam, organised by @recantha and @geeky_tim. Despite being only a few weeks into the project, we are keen to join the very welcoming Raspberry Pi community in Cambridge and get feedback on our idea as early as possible so they can shape the development of project, instead of simplify being an after through.
The router that I am building OpenWRT for is TL-WDR3500 TL-WDR3600. I will be building Attitude Adjustment, Backfire branch
(1) Set up build environment
$ sudo apt-get install subversion build-essential libncurses5-dev zlib1g-dev gawk flex quilt git-core
The following is a quick guide to setting up an virtual server on Amazon Cloud EC2:
1) Login to AWS Management Console using your Amazon account and navigate to EC2
2) In the top right hand corner, check that the location of the servers is the one that you would like to use, I will be using Ireland
3) In the “Getting Started” section of the EC2 dashboard, select Launch instance to create a new virtual server
4) I will be demonstrating the “Classic Wizard”
5) Select the Amazon Machine Image (AMI) that you would like to use, I will be using the Amazon Linux AMI 2012.09, 64bit edition
6) Enter the instance details, I am going to be creating 1 micro instance on EC2 so I’ve not changed any of the options on this page or the following Advanced Instance Options page or Storage Device Configuration page
7) Now you can create tags, using tags for your instances is really useful so I highly recommend it. I’ve set the key and value to “PAWS-router-management-server”
8) Creating a public/private key is vital for using SSH to access your virtual server. Give the private key a sensible name and download it
9) Creating a new security group is highly recommended, otherwise you can use make use the default group. I will be accessing the server using SSH so I’ve opened up port 22 to SHH
10) Review the opinions you have chosen and save
1) If you navigate to the “instances” page, you will now be able to see your newly created instance. Selecting your instance will give you access to more detailed information
2) To access your new instance, open the terminal and locate the private key you downloaded during set up
3) Change the permissions on the key using: $ chmod 400
4) Connect via SSH using: $ ssh -i
More details on the Amazon Linus AMI are available at http://aws.amazon.com/amazon-linux-ami/ . Its useful to note that there is no root password, you can’t SSH in as root or use su but if you use sudo, no password is required and that the package manager used is yum
OpenWrt is a firmware for embedded devices used to router traffic. In this case we will be considering the use of OpenWRT in domestic routers such as the test hardware Linksys Wireless-G Broadband Router WRT54GL v1.1.
Before installing OpenWrt on a router, you must enable that the device is OpenWrt compatible, you can do this my ensuring the device is listed here
Before exploring OpenWrt, We are going to take a closer look at the hardware available:
CPU: Broadcom BCM5352 @ 200 MHz
RAM: 16 MB
Flash Memory: 4 MB
QUICK CHECK – to ensure the hardware is what we believe it to be, we can check the prefix of the serial number using the information here
This hardware is fully supported by OpenWrt, but there have been issues with the limited amount of flash memory:
The solution to this issues, has also been documented. This is to use OpenWrt 8.09 r14511 (code name “kamikaze”) instead of the most up-to date version OpenWrt 10.03.1-rc6 (code name “backfire”)
PICKING A VERSION
To start with we are going to install OpenWrt in Linksys Web GUI. There are many versions of OpenWrt available, so we need to identify to first version we will try:
- The OpenWrt version is Kamilaze, due to a bug in backfire and instability of attitude adjustment
- The recommended version is 8.09 within Kamilaze
- The CPU is broadcom so the prefix is bcrm
- For here, i can see the hardware supports both brcm-2.4 and brcm47xx
- The difference between brcm-2.4 and brcm47xx is explained here
- For ease, we will download a image file, this will end with .bin
- If both JFFS2 and SquashFS is available, use SpuashFS images
- Look into the version history to determine with version of 8.09 is best and what is different between kamikaze, backfire and attitude adjustment
The image I am going to test is http://downloads.openwrt.org/kamikaze/8.09/brcm-2.4/openwrt-wrt54g-squashfs.bin
Step 1: Download http://downloads.openwrt.org/kamikaze/8.09/brcm-2.4/openwrt-wrt54g-squashfs.bin to my Downloads directory
Step 2: Plug in router to mains and to computer via ethernet (use port 1 not internet port)
Step 3: Direct the browser to http://192.168.1.1 and log in
Step 4: Navigate to Administation > Firmware update, select openwrt-wrt54g-squashfs.bin and update
ALL IS LOOKING WELL
COMMUNICATION VIA WEB GUI
Direct the browser to http://192.168.1.1, log in and your presented with the web interface luci
COMMUNICATION VIA TELNET
The router should now be telnet(able) to 192.168.1.1. To test this:
$ telnet 192.168.1.1
This returns the recipe for KAMIKAZE
Now to ensure that tftp is available to prevent bricking, enter:
$ nvram set boot_wait=on $ nvram set boot_time=10 $ nvram commit && reboot
COMMUNICATION VIA SSH
The network configuration is stored in /etc/config/network. The initial contents of this file for our set up is:
The content of the initial configuration file is
#### VLAN configuration
config switch eth0
option vlan0 “0 1 2 3 5*”
option vlan1 “4 5″
#### Loopback configuration
config interface loopback
option ifname “lo”
option proto static
option ipaddr 127.0.0.1
option netmask 255.0.0.0
#### LAN configuration
config interface lan
option type bridge
option ifname “eth0.0″
option proto static
option ipaddr 192.168.1.1
option netmask 255.255.255.0
#### WAN configuration
config interface wan
option ifname “eth0.1″
option proto dhcp
Once we have edited this file, to make the new configuration take after we need to :
$ /etc/init.d/network restart
The switch section of the above configuration file is responsible for making one peoice of hardware, appear as several independent interfaces. The part of the configuration file which specifies the switch characteristics is:
#### VLAN configuration
config switch eth0
option vlan0 “0 1 2 3 5*”
option vlan1 “4 5″
In the above configuration: The numbers 0-5 represent the port numbers, so VLAN0 includes ports 0 to 5* and VLAN1 includes ports 4 and 5. The * in 5*
indicates the PVID.
As shown in the above diagram, this switch separates the LAN ports and thWAN ports .
The other statements in the configuration file describe the interfaces. The interfaces are logical networks, for the setting of IP address, routes and other magic.
The 3 interfaces that we have here are named loopback, lan and wan. The physical interfaces associated with these logical interfaces are lo, eth0.0 and eth0.1.
The following are the notes I’ve taken from the lectures and labs at my first day here at Google, London. This is a first draft and they are very brief, taken in quite a rush. The primary reason for my placing them here on my blog so they that they can be used by other people here with me at the camp.
The android platform lauched in October 2008, it now has over 400 million devices registered. Currently, more than 1 million devices are registered each day. There are over 600, 000 applications in the Google Play store, this highlights the quality of the development tools but this also means that there is a lot of competition so applications need to be high quantity across the supported devices.
|This diagram shows the Android Development Architecture|
The main layers that I will be focusing on are the application layer and the application framework. The android platform makes use of Java Modeling Language (JML).
The lastest Android OS is nicknamed Jelly Bean (its 4.1).
The Android Development that takes place here in London includes youtube, Play Videos, Voice Search, Voice IMF and Chrome
Chrome is NOT a port of chromium. It was first released in February 2007. The current Chrome beta is based on chromium18.
The reason that applications looks difference to their web implementations is to make use of different user interaction methods (such as touch) and to work around limitations (such as screen size).
GMS- a set of applications separate from the OS but are communally shipped with the platform.
Environment & Ecosystem
UI Design & Development
More information on design for android is available at d.android.com/design.
The primary form of user interaction is touch so you need to consider factors such as the size of the users fingers. The design of the mobile applications must be intuative to a user on the go. The Android OS runs on 1000 difference devices so you need to consider factors like screen size or if the device has a keyboard.
- Pictures are faster than words
- Only show what you need to
- Make important things fast
Every OS has a different look and feel. The current system theme is called “Holo” visual language. You can vary holo to get dark (e.g. media apps), light (e.g. productiveity) or light with dark productivty bar.
The structure of the android UI is (from the top down) the action bar (required), tabs (optional) and contents.
The action bar has 4 elements (from left to right):
- Application icon & optional up control
- View control (such as a page title and dropbox) – this woulds a bit like tabs, this shows where you are using the page title and then when you can go from there via the dropbox
- Action buttons – typical examples include search, share, new, edit, sort
- The action overflow – an extra dropbox for extra buttons, a typical example is settings
On smaller screens some action buttons get pushed onto overflow.
The action bar is automatically added on modern application and ActionBarSherlock can be used to achieve backwards compatibility.
You can customize the action bar with the .getActionBar().setDisplayoptions() method
Tabs are available as part of the ActionBar API and usually can also be switched with gestures
The layout of the content is defined as a tree consisting of view groups (tree nodes) and views (tree leaves).
The layout of the content is most commonly defined in XML under res/layout
A view is an individual component such as button, text box or radio button. All views are rectanglar.
A view group is an ordered list of views and view groups. View groups can be divided into two categories: layouts and complex view groups. The key layouts are frame, linear, relative and grid. The key complex view groups are list views and scroll views
The action bar is not defined in XML or is includes as the contents.
The xml files defining the layout of a particular activity are located in res/layout. You can also specify the layout for a particular screen size or orientation. For example if you wanted to use a different layout the nexus 7 compatred to a typically android phone when you can put the XML files in layout-large. If there is no particular layout specified in res/layout-large then the layout in res/layout will be used automatically. Other files include res/layout-land and res/layout-large-land
The universal application binary will contain all resources and then the system choose at run time which resource to use.
A similar situation is true of the drawables, for example this is: drawable-xhdip for extra high dots per pixel.
A really interesting and useful file type of drawables is “9 patch PGN” and it is well worth researching
The res/values/strings.xml file contains all string that will be displayed to the user, the purpose of this is so that the application can be quickly translated to other languages.
The string in this file can be referenced using R.string.hello in Java or @string/hello in XML, where hello is replaced by the name of the string.
You can access an icon, such as the system edit icon using android.R.drawable.ic_menu_edit in Java.
dip stands for density independent pixel which means that if i create a button that 30 dip wide, then on whatever device the application is run on, then the physical size remains the same. This is useful for example when you want to ensure that a button will always be just large enough for the user to click on.
1 dip = 1 pixel at 160 dpi
The nexus 7, has 213 dpi, has a screen size of 1280 x 800 pixels or 960 x 600 dip.
The key drawable types are Bitmaps (.png), 9-patches (.9png) and state lists (.xml).
Look at the SDK for more information on how to draw 9 patches. 9 patches are density specified versions on an image that can be stretched.
State lines are used to specify then different graphics are used in different situations for example showing one graphic when button is pressed and another graphic for then the button is not pressed.
ASIDE: its vital to always give the user feedback
Styles can be specified in /res/values/styles.xml. With the file starting with
The following is a look at the code here on GitHub. If you’ve been following my progress so far you will know that I’ve so far managed to run this code, but I am let to take a proper look at the code and how it works.
The top level of the directory contains the following directories/files, typical to an Android project:
- directory called /res that contains the launcher icon, the xml file describing the layout, and two further xml files which hold the “values” associated with the application
- directory called /src that containing 4 java files LocalBinder.java, SigcommDemoAndroidActivity.java, SigcommDemoAndroidService.java and TestsSignpost.java and a collection of java files for different data views
- the AndroidManifest.xml file which highlights that the minimum SDK version is 10
- the lint.xml file which contains almost nothing
- the pom.xml file, I’m currently not sure what this does
- the project.properties file which just re-highlights that the SDK is version 10
I’m now going to take a closer look at the code:
- onCreate(Bundle savedInstanceState) - the method that is called when the application is first started
- onDestroy() – the method that is called when the application is closed
- onPause() – the method that is called when the application is paused
- onClick(View v) – the method that is called when either of the two buttons on the application is pressed, v.getId() is then used to determine which button was pressed
- updateTimestampArray (float  array, float newval) – this method shifts all of the values in the array to the left by one position, disregarding the value at index 0 and inserting newval at the last place in the array. There are also minValBandwidth and maxValBandwidth which are updated according
- updateHistoricValFloat (float  array, float newval ) – this method shifts all the values in the array to the left by one position, disregarding the value at index 0 and inserting newval at the last place in the array. [Note: the difference between updateTimestampArray and updateHistoricValFloat is that only updateTimestampArray updates the minValBandwidth and maxValBandwidth ]
- plotLatencyPairs (float  timestampsDownstream, float  arrayLatencyDownstream, float timestampsUpstream, float arrayLatencyUpstream) – this method plots latency pairs
- plotBandwidthPairs (float  timestampsDownstream, float  arrayBandwidthDownstream, float timestampsUpstream, float arrayBandwidthUpstream) – this method plots bandwidth pairs
- printVals(int  array) – this method takes an array of integers, turns them into a string with the values separated by commas and sends them to the INFO log file [Note: API on the log output for android is available here and further information is here]
- updateHistoricValInt (int  array, int newval ) – this method shifts all the values in the array to the left by one position, disregarding the value at index 0 and inserting newval at the last place in the array. [Note: the difference between updateHistoricValInt and updateHistoricValFloat is that updateHistoricValFloat takes a float array and updateHistoricValInt takes a int array]
- setMainActivity(SigcommDemoAndroidActivity activity, int  server, int tcpPort) – this method is how SigcommDemoAndroidActivity.java calls this java file. SigcommDemoAndroidActivity.java calls this method when the user click on the start test button on the UI. This method using the data from SigcommDemoAndroidActivity to initialise some of the variables in SigcommDemoAndroidService such as server ip address and port number
- stopThread() – this method simply just re-sets the boolean flag testAlive
- onBind(Intent arg0) – this method calls the constructor of LocalBinder.java and passes the current instance of SigcommDemoAndroidService to LocalBinder.java
- onUnbind(Intent intent) – this method seems to do nothing :S
- onDestroy () – this method calls the onDestroy() on the class Service that SgcommDemoAndroidService inherits from
- onCreate() – this method calls the onCreate() on the class Service that SgcommDemoAndroidService inherits from and creates a new thread called th
- callFinalize() – this method calls System.exit(0)
- notifyActivity (int value, int caseId) – this method refreshs values
- run () – this method connects to the server and measures the time for packets to be transported between client and server
This is blog post number 4, on try to run Iperf on Android, my previous attempts were:
- Method 1 – getting the Google Play Store on a CyanogenMod phone and downloading the Iperf for Android application
- Method 2 – SSHing into an Android phone and trying to run Iperf from the command line
- Method 3 – repeating method 1 & 2 on another Android phone and trying a different application called Aperf
- Method 4 – trying to run a cross-compiled version of Iperf on the Android phone
- Potential Method 5 – cross-compile Iperf myself and try to run that version
- Potential Method 6 – install Linux on android, following instructions here.
- Potential Method 7 – write my own version of Iperf
- Get to grips with the basics of Android Debug Bridge (adb)
- Download the cross compiled Iperf and push it onto SD card
- Copy Iperf over the correct location in the system
Android Debug bridge (adb) is a command line tool for communicating with an android device via USB or an emulator instance. adb is not installed in the machine so it must be ran from the correct location, for me this was android-sdk-linux/platform-tools/.
I connect my android phone via USB and run ./adb devices to test that the device is connected. If multiple emulators/device instances are running then I will need to specify with device to use when using adb so for simplicity, I close all running emulators so that I have only my android phone running.
(* starts a remote shell on the android device, the command prompt becomes # *)
mount -o rw,remount /system
(* remount the /system filesystem so that its now read-write *)
cp /sdcard/iperf /system/bin
(*copy the iperf code over to newly remounted /system filesystem *)
mount -o ro,remount /system
(* remount the /system filesystem so that its now read-only *)
Now I try iperf, from the remote shell and IT WORKS !
Yes, that’s right, it works perfectly. This time it was 4th time lucky.
And this right here, is the reason that I’m a computer scientist. For the high, that you get when something finally works and you know that it works because you made it work. Looking back over the past few days, I feel like I’ve learned so much about Android and given the opportunity I would definitely do it all over again but now its time for a coffee.
My current aim is to get Iperf running on an Android phone so that I can collect “accurate” network data to compare to the network data produced by Signpost Demo Application that I’m currently trying to test.
The problem is that I can’t get the Iperf for Android application to run on any of the available android phones. I have also tried SSHing into the phone and running Iperf, this also did not work.
I need to get Iperf working on android to collect the data for comparison to data produced by the demo code. The back up plan will be to write my own application to collect the required network data, but I would like to have Iperf working so that I can test my own application.
If anyone has suggestions of tools to collect network data like bandwidth, latency, goodput and jitter, that work on linux and android using a client server architecture, then comment below.
So, I’ve got my hands on yet another android phone, I think this is phone number 6 or something like that. It is a HTC Magic, that is currently not rooted. I boot it up, get it going and download the Iperf for Android application and …
…. it still will not work
So, I do some research and I come across another application that claims to also act as an Iperf cleint, this one is called Aperf. I install it on two different android phones, test and …
…. it still will not work
Repeating the tests, changing Wi-Fi networks and finally it works, The following results are from the Iperf server
[ ID] Interval Transfer Bandwidth
[ 4] local
[ 4] 0.0- 8.9 sec 30.0 KBytes 27.6 Kbits/sec
[ 5] local
[ 5] 0.0- 6.0 sec 47.0 KBytes 64.3 Kbits/sec
[ 4] local
[ 4] 0.0- 6.6 sec 132 KBytes 164 Kbits/sec
[ 5] local
[ 5] 0.0- 6.6 sec 400 KBytes 496 Kbits/sec
[ 4] local
[ 4] 0.0- 6.5 sec 103 KBytes 131 Kbits/sec
[ 5] local
[ 5] 0.0- 8.6 sec 697 KBytes 662 Kbits/sec
[ 4] local
[ 4] 0.0- 5.1 sec 59.0 KBytes 94.3 Kbits/sec
[ 5] local
[ 5] 0.0- 5.9 sec 386 KBytes 539 Kbits/sec
[ 4] local
[ 4] 0.0- 8.6 sec 35.0 KBytes 33.3 Kbits/sec
[ 5] local
[ 5] 0.0- 8.2 sec 332 KBytes 331 Kbits/sec
The information above dose not show the complete picture. This data was collected from the server, in each case the client has only transmitted data for 5 seconds, this means that the bandwidth values above as incorrect. To calculate the correct bandwidth values I need to take amount of data transferred and divide by 5 seconds.
The client dose not seem to output any data except that required to calculate bandwidth. Using UDP instead of TCP dose not seem to allow me to collect any more information.
Ironically the network statistics collected by the Signpost diagnosis android app are latency, goodput and jitter but the only network statistics that I am able to collect is bandwidth.
I do not know where to go forward from here, I need accurate network statistics between a android client and Linux server so I can test the code. I could write my own application to collect the data, but then I will have the same problem again as I need accurate network statistics to check my application is working correctly
Any suggestions ??
Due to the issues with the Iperf application for android and part of the touch screen on my andriod phone not working properly, I’ve decided that it would be best to set up SSH to remote access on android phone, to make working with the phone easier.
To application that I decided to use to help get my SSH running on as quickly as possible was SSHDroid. This is an excellent application that I would highly recommend. The steps in setting up SSH access where:
- Install SSHDroid and launch application
- Change the password from its default which is “admin”
- Install OpenSSH on your linux computer
- run ssh root@
- Enter password when requested
Now I have the command line of the android phone, I downloaded iperf and extracted the contains of the .tar.gz file to the SD card. The next stage in my plan was to use ./configure then make then make install as per usual.
But as ever, thing are never that straight forward.
- on doing ./configure, I get permission denied
- on doing sudo ./configure, I get sudo: not found
- on doing echo $USER, I get root
- on doing ls -l | grep configure, I get —xrwxr-x
so why will it not work ?
I’ve managed to deal with the “Permission Denied” error despite having root access and the correct permission by prefixing ./configure with sh. This then fails to compile due to the lack of a C++ compiler
Today, I am going to take a look at Iperf and get it running between my server (written in Ocaml and running my laptop) and client (on an android phone). To avoid the issues with IP addresses, I will use the same Wi-Fi network for both the client and server so that both devices are behind the same NAT box and can address each other using the private IP addresses. In this case, (like before) I only need the IP address of the server, which I will get from connection information in Ubuntu 12.04.
Iperf is already installed the server (my laptop) from when I was using Iperf to test the network properties of Tor such as latency, bandwidth and packet-loss. This was before starting this blog. I assume that Iperf was not included in Ubuntu 12.04 and that I got it via “sudo apt-get install iperf” (someone please correct me if I am wrong in this assumption)
Getting on Iperf on the client (an android phone) is a little more complex. Iperf has an android application at the google play store but my android phone does not have an app store as its running CyanogenMod. The paragraph at the top of this wikipedia article explains why there is no build in google play store
The following instruction where taken from this YouTube video. To do this you will need a micro SD card and a USB adaptor
To get the Google Play Store on CyanogenMod:
- Download the correct version of gapps from here
- Copy the .zip file of gappy onto the micro SD card and put SD back into phone
- Reboot in recovery mode
- Select flash zip from SD card and then the gapp file
- Reboot android phone
- Sign-in to your Google account
Then I simply get the Iperf application from the Google Play Store by searching Iperf.
The Iperf application on android don’t seem to work, The application will load and allow me to enter an Iperf command, in this example I am simply entering -s and click Done, but then nothing happens. If I click the button with “off” on, it momentary turns green and says on before returning to off.
So as per usual its time for some trouble shooting checks:
- Is the application for my version of andriod ? Yes, the application requirement is 1.5 or up and my version is 2.3.7
- Is there network connectivity ? Yes
- Is the command that I’m test correct ? Yes -s is the example used for screenshots on Google play, also other commands like -c also don’t work
- Is this a known bug ? nope, source here
I’ve posted the question on stackoverflow here
Whilst I wait and see if anyone can help with my problem. I am going to take a look into the world of Android terminal emulators to see if I could run Iperf this way instead if the android application still fails to work or maybe I can ssh into the phone and run iperf. CyanogenMod comes with a terminal emulator, which I will use for now