User Tools

Site Tools


content:tech:serval_mesh_for_firefoxos

This is an old revision of the document!


Serval Mesh app for FirefoxOS

FirefoxOS is an attractive platform for Serval Mesh (app for Android) because it targets low-cost mobile devices and is likely to be adopted rapidly by vendors and carriers in developing countries who seek to avoid the compliance and commercial obligations imposed by Google, Apple and other platform suppliers.

A port of the Serval Mesh app to FirefoxOS would pose the following technical challenges:

  • rewrite the user interface in HTML5 using FirefoxOS API (on Android is written entirely in Java/XML using the Android API)
  • port the Serval DNA daemon toFirefoxOS (see below)
  • the following interactions between Serval Mesh and FirefoxOS would have to be made usable:
    • dialler screen for making and receiving calls
    • contact list for managing known Serval Identities
    • text message sending and receiving
    • app manager for auto-upgrade via Rhizome
    • gallery and camera for sending and receiving photos via Rhizome
    • file manager for sending and receiving files via Rhizome

Serval DNA on FirefoxOS

The Serval DNA component cannot be ported to FirefoxOS as a native Linux executable because FirefoxOS does not and will never provide a native code facility.

It may be possible to translate the Serval DNA C source code to JavaScript using Emscripten. The following technical issues would have to be surmounted:

Daemon process

Serval DNA uses Posix process control system calls like fork(2), _exit(2) and signal(2) to create and control a background daemon process. These are probably not available on FirefoxOS. Instead, the FirefoxOS Background Services API (only in proposal stage as at September 2013) would have to be used, necessitating a rewrite of the daemon control logic.

Persistent storage

Serval DNA uses Posix file system calls such as open(2) for persistent storage of the keyring file, configuration, logging, and temporary storage of Rhizome payloads. These would have to be rewritten to use the FirefoxOS Device Storage API.

Inter-process communication

Serval DNA uses local filesystem-bound sockets and named pipes for communication between client and daemon processes. These would have to be rewritten to use abstract local sockets (if supported) or local port numbers (if supported) or some other IPC mechanism not yet proposed (as at September 2013) in FirefoxOS.

SQLite

Serval DNA uses SQLite for persistent storage of Rhizome bundles. On Android, the SQLite library contributes signficantly to Serval Mesh's APK binary size and consumes a great deal of CPU and RAM overhead with its data indexing and consistency. The SQLite library may not scale well to low-end devices if compiled with Emscripten and executed as JavaScript.

  • Cryptographic operations such as signature verification and payload encryption are performed on Android using the native NaCl library which has been optimised for the ARM processor. This optimisation brings Serval's security features within reach of low-end devices. The Emscripten compiled code has known speed limitations, so how much CPU overhead will that introduce to crypographic operations? Would that make Serval Mesh for FirefoxOS unusable in practical terms due to slowness and battery drain?
  • Any port of Serval DNA must be controlled for quality using the automated test suite, which is a set of Bash scripts executed natively on the target platform. The Emscripten JavaScript port of Serval DNA would have to be invokable via the normal Serval DNA command-line interface, from an Emscripten port of Bash running the test framework script within a Posix environment that may include Emscripten ports of standard Posix utilities like grep, sed and awk.
  • The MDP packet assembly/disassembly code has been shown to be largely correct and portable to different-endian architectures (ARM, Sparc, Intel 32-bit and 64-bit) but it may not work correctly when compiled by Emscripten, so will need extensive testing on a heterogeneous network and may need some rewriting.
content/tech/serval_mesh_for_firefoxos.1378345926.txt.gz · Last modified: 04/09/2013 18:52 by Andrew Bettison