|
1 | 1 | ---
|
2 |
| -title: Building from sources (Android) |
| 2 | +title: Running as an app (Android) |
3 | 3 | parent: Installation
|
4 | 4 | nav_order: 40
|
5 | 5 | ---
|
6 | 6 |
|
7 |
| -# Building from sources (Android) |
8 |
| - |
9 |
| - |
10 |
| -{% include alert type="Danger" title="Attention needed" content=" |
11 |
| -This page is supposed to be rewritten. Procedures described here are highly outdated and are not guaranteed to work. |
12 |
| -" %} |
13 |
| - |
14 |
| - |
15 |
| - |
16 |
| -## Introduction |
17 |
| -It is possible to run SCION on an Android device. The easiest way is to install [SCION as an Android app](#scion-app). The other alternative is to [manually install SCION on your Android device](#manual-setup). Both variants are based on [Termux](https://github.com/termux/termux-app), which emulates a Terminal environment with the Linux base system that Android is based upon. |
18 |
| - |
19 |
| -This tutorial is primarily targeted at running a SCION end host on Android. While it is also possible to run an entire SCION AS, this currently doesn't run stable within Termux, as it requires Apache Zookeeper, which frequently crashes the Termux environment as described [here](#endhost-configuration-vs-full-as). |
| 7 | +# Running as an app (Android) |
20 | 8 |
|
| 9 | +{% include alert type="warning" title="Warning: Beta version" content="The SCION Android apps are still in beta and are not guaranteed to work." %} |
21 | 10 |
|
22 | 11 | ## Prerequisites
|
23 |
| - |
24 |
| -It is recommended to make yourself familiar with Termux by reading the [Wiki](https://wiki.termux.com/wiki/Main_Page) to learn how the app can be used comfortably. |
25 |
| - |
26 |
| -## SCION App |
27 |
| - |
28 |
| -{% include alert type="hint" content=" |
29 |
| -The SCION App is currently in testing. With this App we aim to provide an easy way to install SCION on Android, so that the [manual setup](#manual-setup) won't be necessary anymore. |
30 |
| -" %} |
31 |
| - |
32 |
| -To install the SCION app, please contact [Stefan Schwarz ](mailto:[email protected]) to get an invite to the App testing group. |
33 |
| - |
34 |
| -Once you have been added to the group, you will receive an email with a link to the SCION App. Note that the SCION App is currently distributed through HockeyApp and thus requires to install it as well. This can be done [through the HockeyApp website](https://hockeyapp.net/apps) (it is not available on the Google Play Store). |
35 |
| - |
36 |
| -#### Install SCION with the SCION App |
37 |
| - |
38 |
| -Once the SCION App has been installed, open it and run the following command within the Terminal (Wifi connection recommended): |
39 |
| -```shell |
40 |
| -./install |
41 |
| -``` |
42 |
| - |
43 |
| -That’s it! The process takes a while but is fully automatic. At the end, a dialog opens which asks to select the ‘gen’ folder from internal memory. Select it to continue. |
44 |
| - |
45 |
| -{% include alert type="hint" content=" |
46 |
| -If the folder selection doesn't show up, run the following script to trigger it manually: `./import_folder` |
47 |
| -" %} |
48 |
| - |
49 |
| -That means of course, that the ‘gen’ folder needs to be readily available on the internal memory. Download it directly or push it onto the device with ADB. |
50 |
| - |
51 |
| -{% include alert type="warning" content=" |
52 |
| -SCION for Android currently only supports a SCION end host configuration, as described [in this tutorial](../config/setup_endhost.html) |
53 |
| -" %} |
54 |
| - |
55 |
| -{% include alert type="warning" content=" |
56 |
| -SCIOND config in the ‘gen’ folder needs a little adjustment on Android, as described [here](#changes-to-gen-folder) |
57 |
| -" %} |
58 |
| - |
59 |
| - |
60 |
| -## Manual setup |
61 |
| - |
62 |
| -To setup SCION on Android manually, the [Termux app](https://play.google.com/store/apps/details?id=com.termux) needs to be installed from the Google Play Store. |
63 |
| - |
64 |
| -To install SCION within Termux it is recommended to access the Termux environment via the Android Debug Bridge (ADB) or via SSH. |
65 |
| - |
66 |
| -### Access Termux via SSH |
67 |
| - |
68 |
| -First install the `openssh` package within Termux with `pkg install openssh`, then start the server with `sshd`. Password authentication is not supported, so you need to add your public key to `$HOME/.ssh/authorized_keys`. The ssh server runs by default on port 8022, so connect to it with `ssh -p 8022 DEVICE_IP`. You can find the device IP address with `ip addr list wlan0`. |
69 |
| - |
70 |
| -For more information: |
71 |
| -[Run an SSH server on your Android with Termux](https://glow.li/technology/2015/11/06/run-an-ssh-server-on-your-android-with-termux/) |
72 |
| -[Access Termux via USB](https://glow.li/technology/2016/9/20/access-termux-via-usb/) |
73 |
| - |
74 |
| -### Install necessary packages |
75 |
| - |
76 |
| -Install the required packages from within Termux: |
77 |
| - |
78 |
| -```shell |
79 |
| -apt update && apt upgrade |
80 |
| -pkg install -y termux-exec git python python2 clang make python-dev libffi-dev openssl-dev openssl-tool curl |
81 |
| -``` |
82 |
| - |
83 |
| -To access the SD card from Termux, it is required to run `termux-setup-storage` from the Termux console. |
84 |
| - |
85 |
| -### Configure Go workspace |
86 |
| - |
87 |
| -SCION requires a specific Go version. The Termux Go package may be ahead of that version. The following repository offers prebuilt golang packages in the required version for both ARMv7 & ARMv8/aarch64 architectures: |
88 |
| - |
89 |
| -For ARMv7: |
90 |
| -```shell |
91 |
| -curl -O https://raw.githubusercontent.com/stschwar/scion/termux-modifications/debian-packages/arm/golang-doc_2%3A1.9.4_arm.deb |
92 |
| -curl -O https://raw.githubusercontent.com/stschwar/scion/termux-modifications/debian-packages/arm/golang_2%3A1.9.4_arm.deb |
93 |
| -dpkg -i golang_2%3A1.9.4_aarch64.deb golang-doc_2%3A1.9.4_aarch64.deb |
94 |
| -``` |
95 |
| - |
96 |
| -For aarch64: |
97 |
| -```shell |
98 |
| -curl -O https://raw.githubusercontent.com/stschwar/scion/termux-modifications/debian-packages/aarch64/golang-doc_2%3A1.9.4_aarch64.deb |
99 |
| -curl -O https://raw.githubusercontent.com/stschwar/scion/termux-modifications/debian-packages/aarch64/golang_2%3A1.9.4_aarch64.deb |
100 |
| -dpkg -i golang_2%3A1.9.4_aarch64.deb golang-doc_2%3A1.9.4_aarch64.deb |
101 |
| -``` |
102 |
| - |
103 |
| -Setup the Go workspace and add it to your path: |
104 |
| - |
105 |
| -```shell |
106 |
| -echo 'export GOPATH="$HOME/go"' >> ~/.profile |
107 |
| -source ~/.profile |
108 |
| -mkdir -p "$GOPATH/bin" |
109 |
| -echo 'PATH=$PATH:$GOPATH/bin' >> ~/.profile |
110 |
| -source ~/.profile |
111 |
| -``` |
112 |
| - |
113 |
| -## Install SCION |
114 |
| - |
115 |
| -### Step One – clone the SCION repository |
116 |
| - |
117 |
| -After the Go workspace has been configured, we can checkout SCION with the required Termux modifications from Github and apply a required patch using the following commands: |
118 |
| - |
119 |
| -```shell |
120 |
| -mkdir -p "$GOPATH/src/github.com/scionproto/scion" |
121 |
| -cd "$GOPATH/src/github.com/scionproto/scion" |
122 |
| -git config --global url.https://github.com/.insteadOf [email protected]: |
123 |
| -git clone --recursive -b termux-modifications [email protected]:stschwar/scion . |
124 |
| - |
125 |
| -curl -O https://raw.githubusercontent.com/stschwar/scion/termux-modifications/patches/lwip-contrib.patch |
126 |
| -patch sub/lwip-contrib/ports/unix/proj/scion/Makefile lwip-contrib.patch |
127 |
| -rm lwip-contrib.patch |
128 |
| -``` |
129 |
| - |
130 |
| -This will clone the appropriate SCION directory into your Go workspace. We will create an environment variable `SC` that will point to the SCION root directory. Afterwards it is necessary to navigate to the newly downloaded repository for finishing the configuration: |
131 |
| - |
132 |
| -```shell |
133 |
| -echo 'export SC="$GOPATH/src/github.com/scionproto/scion"' >> ~/.profile |
134 |
| -source ~/.profile |
135 |
| -cd $SC |
136 |
| -``` |
137 |
| - |
138 |
| -### Step Two – configure Python path variable |
139 |
| - |
140 |
| -Some SCION components like SCIONviz require Python libraries which are located in the SCION root directory. In order to make them accessible, the `PYTHONPATH` environment variable needs to be exported: |
141 |
| - |
142 |
| -```shell |
143 |
| -echo 'export PYTHONPATH="$SC/python:$SC"' >> ~/.profile |
144 |
| -source ~/.profile |
145 |
| -``` |
146 |
| - |
147 |
| -### Step Three – install required packages/patches |
148 |
| - |
149 |
| -SCION has an install script to install all necessary dependencies. In the Termux environment, however, this is not yet working. So the dependencies have to be installed manually. |
150 |
| - |
151 |
| -#### Cap'n Proto |
152 |
| - |
153 |
| -To install [Cap'n Proto](https://capnproto.org/) in Termux run the following commands in the `home/` directory: |
154 |
| - |
155 |
| -```shell |
156 |
| -curl -O https://capnproto.org/capnproto-c++-0.6.1.tar.gz |
157 |
| -tar zxf capnproto-c++-0.6.1.tar.gz |
158 |
| -cd capnproto-c++-0.6.1 |
159 |
| -``` |
160 |
| -On Termux Cap'n Proto requires some patching to compile: |
161 |
| -```shell |
162 |
| -cd src/kj/ |
163 |
| -curl -O https://raw.githubusercontent.com/stschwar/scion/termux-modifications/patches/capnproto-c++-0.6.1/debug.c++.patch |
164 |
| -patch debug.c++ debug.c++.patch |
165 |
| -rm debug.c++.patch |
166 |
| -``` |
167 |
| - |
168 |
| -Back in the `capnproto-c++-0.6.1/` root directory run: |
169 |
| -```shell |
170 |
| -./configure --prefix=$PREFIX TMPDIR=$PREFIX/tmp |
171 |
| -make |
172 |
| -make install |
173 |
| -``` |
174 |
| - |
175 |
| -#### zlog |
176 |
| - |
177 |
| -Install [zlog](https://github.com/HardySimpson/zlog) by following its install instructions mostly. It requires some more patching and the installation of `libandroid-glob-dev`: |
178 |
| - |
179 |
| -```shell |
180 |
| -curl https://codeload.github.com/HardySimpson/zlog/tar.gz/latest-stable --output zlog-latest-stable.tar.gz |
181 |
| -tar -zxf zlog-latest-stable.tar.gz |
182 |
| -cd zlog-latest-stable/ |
183 |
| -curl -O https://raw.githubusercontent.com/stschwar/scion/termux-modifications/patches/zlog-makefile.patch |
184 |
| -patch src/makefile zlog-makefile.patch |
185 |
| -rm zlog-makefile.patch |
186 |
| - |
187 |
| -pkg install -y libandroid-glob-dev |
188 |
| -make PREFIX=$PREFIX |
189 |
| -make PREFIX=$PREFIX install |
190 |
| -``` |
191 |
| - |
192 |
| -#### uthash |
193 |
| - |
194 |
| -Install the [uthash](https://troydhanson.github.io/uthash/) library from your `home/` directory: |
195 |
| -```shell |
196 |
| -curl -o uthash-master.zip https://codeload.github.com/troydhanson/uthash/zip/master |
197 |
| -unzip uthash-master.zip |
198 |
| -cp uthash-master/src/*.h $PREFIX/include |
199 |
| -rm -rf uthash-master/ |
200 |
| -``` |
201 |
| - |
202 |
| -#### SCION Python dependencies |
203 |
| - |
204 |
| -Most of the Python dependencies can easily be installed through `pip`: |
205 |
| -```shell |
206 |
| -cd $SC |
207 |
| -pip2 install -r env/pip2/requirements.txt |
208 |
| -pip3 install -r env/pip3/requirements.txt |
209 |
| -TMPDIR=$PREFIX/tmp pip3 install lz4 PyNaCl PyYAML Pygments |
210 |
| -``` |
211 |
| -{% include alert type="Supervisor" content=' |
212 |
| -In case the pip installation of the package "Supervisor" fails, you can install it manually: |
213 |
| - |
214 |
| -```shell |
215 |
| -curl -O https://pypi.python.org/packages/44/60/698e54b4a4a9b956b2d709b4b7b676119c833d811d53ee2500f1b5e96dc3/supervisor-3.3.4.tar.gz |
216 |
| -tar -xzf supervisor-3.3.4.tar.gz |
217 |
| -cd supervisor-3.3.4/ |
218 |
| -python2 setup.py install |
219 |
| -``` |
220 |
| -' %} |
221 |
| - |
222 |
| -#### SCION Go dependencies |
223 |
| - |
224 |
| -With Go correctly installed it is easy to install the SCION dependencies as well: |
225 |
| - |
226 |
| -```shell |
227 |
| -cd $SC/env/go |
228 |
| -./deps |
229 |
| -``` |
230 |
| - |
231 |
| -## Next steps |
232 |
| - |
233 |
| -After finishing the installation of SCION, there are different ways of running different topologies. The following tutorials will cover this in further detail: |
234 |
| - |
235 |
| -1. [Connecting to SCIONLab as an endhost](../config/setup_endhost.html) – Connect to the already running SCION topology as a mobile end host through an existing SCION setup. |
236 |
| - |
237 |
| -#### Changes to gen folder |
238 |
| - |
239 |
| -Note that in `gen/ISDx/AS10xx/supervisord.conf` the path of the SCION Deamon socket needs to be changed as follows: `"--api-addr" "/data/data/com.termux/files/run/shm/sciond/sdX-10XX.sock"`. |
240 |
| - |
241 |
| -#### VPN Connection to SCIONLab |
242 |
| - |
243 |
| -Unfortunately, OpenVPN is not currently supported from within the Termux environment. Alternatively, the [Open |
244 |
| -VPN app](https://play.google.com/store/apps/details?id=net.openvpn.openvpn) can be installed to connect to SCIONLab via VPN. The `client.conf` file that is provided by the [SCIONLab coordinator](https://www.scionlab.org/) needs to be renamed to `client.ovpn` before it can be imported into the app. Additionally, the line `route 10.0.8.0/24` needs to be added to the file. |
245 |
| - |
246 |
| -#### End host configuration vs. full AS |
247 |
| - |
248 |
| -It is possible to run the full SCION on Android, it is, however, currently not recommended. The full SCION requires a Zookeeper instance which itself is a Java program. While it is possible to install a Java Virtual Machine in Termux, the actual Termux packages have been disabled or removed due to instabilities with high CPU usage. |
249 |
| - |
250 |
| -If you still want to try the full SCION on an Android phone, we suggest to use a remote Zookeeper instance running on another device and configuring the own SCION topology accordingly. |
| 12 | +- Android device with at least Android 7 (henceforth referred to as “endhost”) |
| 13 | +- Working scion AS with services set up to be reachable via IP from the endhost |
| 14 | +- SCION endhost app, [available on the Play Store](https://play.google.com/store/apps/details?id=org.scionlab.endhost) |
| 15 | +- SCION sensorfetcher app, [available on the Play Store](https://play.google.com/store/apps/details?id=org.scionlab.sensorfetcher) (optional) |
| 16 | + |
| 17 | +## Import endhost configuration |
| 18 | +1. From your AS' `gen` directory, transfer the `endhost` directory onto your endhost's user accessible storage. |
| 19 | +2. In the endhost's `endhost` directory, find the `sciond.toml` or `sd.toml` file and make the following changes: |
| 20 | + - In the `[sd]` section's `Public` value, replace your AS' IP address (or `127.0.0.1`) with your endhost's IP address. |
| 21 | + - Either: |
| 22 | + - Delete the `[logging.file]` section's entire `Path` assignment. |
| 23 | + - Or replace the `[logging.file]` section's `Path` value with an absolute path that is accessible to you, e.g. `"/sdcard/logs/sd***.log"`. |
| 24 | + - Either: |
| 25 | + - Delete the `[trustDB]`/`[TrustDB]` section's entire `Connection` assignment. |
| 26 | + - Or replace the `[trustDB]`/`[TrustDB]` section's `Connection` value with an absolute path that is accessible to you. |
| 27 | + - Either: |
| 28 | + - Delete the `[sd.PathDB]` section's entire `Connection` assignment. |
| 29 | + - Or replace the `[sd.PathDB]` section's `Connection` value with an absolute path that is accessible to you. |
| 30 | +3. In the endhost's `endhost` directory, find the `topology.json` file and make sure that the endhost can reach the AS' services. |
| 31 | +This usually entails replacing the AS' IP address (or `127.0.0.1`) with the endhost's IP address. |
| 32 | + |
| 33 | +## Starting the dispatcher and sciond |
| 34 | +Open the app and push the “Start dispatcher” button. Your notification drawer should now have a new permanent entry called “Dispatcher service”. |
| 35 | +Push the “Set endhost directory” button. In the dialog that appears, navigate to your endhost's `endhost` directory and press “OK”. Your notification drawer should now have a new permanent entry called “Sciond service”. |
| 36 | +The log files (usually) located in `/sdcard/Android/data/org.scionlab.endhost/files/logs/` should now get populated and not contain error messages. |
| 37 | +Apart from the `/sdcard/` prefix, the dispatcher logs are hardcoded to be in the aforementioned directory, while sciond's logs should either be in the aforementioned directory or where they've been configured to be in the previous step. |
| 38 | + |
| 39 | +## Testing connectivity with scmp |
| 40 | +In the text box, put in command line parameters for a call to the scmp application. These *have to be* newline-separated. |
| 41 | +It is advised to set the `-c` flag to a non-zero value since there is currently no way to gracefully *interrupt* the scmp process, once started. |
| 42 | +An example configuration would look as follows (mind the newlines!): |
| 43 | +``` |
| 44 | +echo |
| 45 | +-local |
| 46 | +[endhost address] |
| 47 | +-remote |
| 48 | +19-ffaa:0:1303,[0.0.0.0] |
| 49 | +-c |
| 50 | +1 |
| 51 | +``` |
| 52 | +Tap the “Start scmp” button to test your endhost's connectivity. |
| 53 | +You should notice movement in your log files. |
| 54 | +With access to your endhost's logcat, you could even see scmp's stdout and stderr outputs. |
| 55 | +If after some seconds, there is a notification titled “Scmp service” mentioning “Scmp returned with value 0”, you have SCION connectivity. |
| 56 | + |
| 57 | +## Testing connectivity with sensorfetcher |
| 58 | +Besides scmp being built into the SCION endhost app, the `sensorfetcher` has been ported to Android as a separate app. Both the local SCION address of the Android endhost and the remote SCION address of a running `sensorserver` have to be specified, as described [here](../apps/fetch_sensor_readings.html). |
0 commit comments