User Tools

Site Tools


content:tech:serval_mesh_for_firefoxos

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
content:tech:serval_mesh_for_firefoxos [03/09/2013 20:47]
Andrew Bettison MDP packet code issues
content:tech:serval_mesh_for_firefoxos [04/09/2013 19:49] (current)
Andrew Bettison link to "no native code" Google group post, add section headings
Line 4: Line 4:
  
 A port of the [[Serval Mesh|Serval Mesh app]] to FirefoxOS would pose the following technical challenges: A port of the [[Serval Mesh|Serval Mesh app]] to FirefoxOS would pose the following technical challenges:
-  * the user interface (which for Android is written entirely in Java/XML using the Android API) would have to be rewritten in HTML5 +  * **rewrite the user interface in HTML5 using FirefoxOS API** (on Android is written entirely in Java/XML using the Android API) 
-  * interactions between Serval Mesh and the following FirefoxOS components would have to be made usable:+  * **port the Serval DNA daemon to FirefoxOS** (see below) 
 +  * the following **interactions between Serval Mesh and FirefoxOS** would have to be made usable:
     * dialler screen for making and receiving calls     * dialler screen for making and receiving calls
     * contact list for managing known Serval Identities     * contact list for managing known Serval Identities
Line 12: Line 13:
     * gallery and camera for sending and receiving photos via Rhizome     * gallery and camera for sending and receiving photos via Rhizome
     * file manager for sending and receiving files via Rhizome     * file manager for sending and receiving files via Rhizome
-  * the [[Serval DNA]] component could not be ported as a native executable because FirefoxOS does not and will never provide a native code facility + 
-  possibly the [[https://github.com/kripken/emscripten/wiki|Emscripten]] C-to-JavaScript compiler could be used to port [[Serval DNA]] to FirefoxOS, but the following issues would have to be investigated to find out if this is feasible: +===== Serval DNA on FirefoxOS ===== 
-    Serval DNA Posix file operations for **persistent storage of the keyring file, configuration, logging, daemon control**, and **temporary storage of Rhizome payloads**.  How would these be achieved within JavaScript on FirefoxOS? + 
-    Serval DNA uses **SQLite for persistent storage of Rhizome bundles**.  On Android, the native SQLite code contributes signficantly to the APK binary size and necessitates a great deal of extra overhead for data indexing and consistency.  This may not scale well to low-end devices if executed as JavaScript. +The [[Serval DNA]] component cannot be ported to FirefoxOS as a native Linux executable because FirefoxOS does not and [[https://groups.google.com/d/msg/mozilla.dev.b2g/rBWBgdvShUc/1BxJAkMtkmwJ|will never provide a native code facility]]. 
-    * **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 [[https://github.com/kripken/emscripten/wiki/CodeGuidelinesAndLimitations|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**. +==== Port using Emscripten ==== 
-    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 [[https://github.com/kripken/emscripten/wiki/CodeGuidelinesAndLimitations|may not work correctly]] when compiled by Emscripten, so will need **extensive testing on a heterogeneous network** and may need some rewriting.+ 
 +It may be possible to **translate the [[Serval DNA]] C source code to JavaScript using [[https://github.com/kripken/emscripten/wiki|Emscripten]]**.  The following technical issues would have to be surmounted: 
 + 
 +== Network access == 
 + 
 +Serval DNA broadcasts its [[MDP]] packets over Wi-Fi by [[Overlay Network|encapsulating]] them in [[http://en.wikipedia.org/wiki/User_Datagram_Protocol|UDP/IP]] packets.  Without packet broadcast, the Serval Mesh cannot work.  The [[http://man7.org/linux/man-pages/man7/socket.7.html|socket]] code would have to be rewritten to use the proposed FirefoxOS UDP Datagram Socket API, which was in early planning stages as at September 2013. 
 + 
 +== Daemon process == 
 + 
 +Serval DNA uses Posix process control system calls like [[http://man7.org/linux/man-pages/man2/fork.2.html|fork(2)]], [[http://man7.org/linux/man-pages/man2/_exit.2.html|_exit(2)]] and [[http://man7.org/linux/man-pages/man2/signal.2.html|signal(2)]] to create and control a background daemon process.  These are probably not available on FirefoxOS.  Instead, the FirefoxOS Background Services API (only [[https://groups.google.com/forum/#!topic/mozilla.dev.webapi/NFXLBW5A0JU|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 [[http://man7.org/linux/man-pages/man2/open.2.html|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 [[https://wiki.mozilla.org/WebAPI/DeviceStorageAPI|Device Storage API]]. 
 + 
 +== Inter-process communication == 
 + 
 +Serval DNA uses [[http://man7.org/linux/man-pages/man7/unix.7.html|local filesystem-bound sockets]] and [[http://man7.org/linux/man-pages/man7/pipe.7.html|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.  This presents several issues: 
 +  * On Android, the  SQLite library contributes signficantly to Serval Mesh'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 [[https://github.com/kripken/sql.js|compiled with Emscripten]] and executed as JavaScript. 
 +  SQLite may depend on certain Posix file operations (eg, [[http://man7.org/linux/man-pages/man2/open.2.html|open(2)]] O_EXCL and [[http://man7.org/linux/man-pages/man2/fcntl.2.html|fcntl(2)]] advisory locking) that are not supported by the FirefoxOS [[https://wiki.mozilla.org/WebAPI/DeviceStorageAPI|Device Storage API]]. 
 + 
 +== Crypto == 
 + 
 +Cryptographic operations such as signature verification and Rhizome payload encryption/decryption are performed on Android using the native [[http://nacl.cace-project.eu/|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 [[https://github.com/kripken/emscripten/wiki/CodeGuidelinesAndLimitations|known speed limitations]], so how much CPU overhead would that introduce to crypographic operations?  Would that make Serval Mesh for FirefoxOS unusable in practical terms due to slowness and battery drain? 
 + 
 +== Test suite == 
 + 
 +Any port of Serval DNA is controlled for quality using the **automated test suite**, which is a [[Bash test framework|set of Bash scripts]] executed natively on the target platform.  This presents an enormous challenge for porting to FirefoxOS, as the test suite relies on a close-to-standard GNU/Posix command-line environment, which may be impossible to achieve under FirefoxOS.  The Emscripten JavaScript port of Serval DNA would have to be invokable via the normal **Serval DNA command-line interface**, from within 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 most likely solution would be to re-implement all or most of the test cases using a test framework built specifically for FirefoxOS. 
 + 
 +== Packet code == 
 + 
 +The [[MDP]] packet assembly/disassembly code functions correctly even when ported to different-endian architectures (ARM, Sparc, Intel 32-bit and 64-bit) but it [[https://github.com/kripken/emscripten/wiki/CodeGuidelinesAndLimitations|may not work correctly]] when compiled by Emscripten.  Extensive testing on a heterogeneous network would be needed, possibly followed by rewriting of the packet code for Emscripten/JavaScript. 
content/tech/serval_mesh_for_firefoxos.1378266473.txt.gz · Last modified: 03/09/2013 20:47 by Andrew Bettison