Ad-hoc mode and olsrd on Samsung Galaxy S with Cyanogenmod 9

… works like a charm.🙂 (Update: But stopped working with CM10 – ad-hoc network are simply not displayed any longer.)

It took me some time to figure out if and how ad-hoc mode is supported in Cyanogenmod 9. I tinkered with wpa_supplicant unsuccessfully just to find out that you don’t have to do anything but configure a static IP address for the wireless network interface. In other words, ad-hoc mode just works out of the box when connecting to an existing wireless peer to peer network. Before, the connection just failed because it tried to receive a dynamic IP address.

Step 1: Configure a static IP address

Go to the wireless networks list on your phone. Select your mesh peer to peer network, e.g. olsr.freifunk.net by long-pressing on it to edit the connection (left screenshot). Tick the advanced settings to see all configuration options. Then enter the following information for a static IP address:

Edit the network configuration
Edit the network configuration

Configuration of a static IP address
Configuration of a static IP address

You can leave the gateway empty, it will be detected automatically. Save the config and connect to the network.

Step 2: Download and install olsrd

Download the precompiled olsrd for Samsung Galaxy S here: http://www.olsr.org/releases/0.5/olsrd-0.5.6-android-samsung-galaxy.tgz. (Information on how to build it yourself can be found here: http://www.olsr.org/?q=olsr_on_android. Note that entering ad-hoc mode with this description did not work for me.). Untar the archive and copy the files to their location in the android file system (e.g. cp system/bin/ff /system/bin/ff). Some of the directories have to be created first.
Update: Also, you’ll have to mount the /system partition writeable:

shell@android:# mount -o remount,rw /system

user@device:$ tar -xzvf olsrd-0.5.6-android-samsung-galaxy.tgz
system/bin/ff
data/local/bin/ff
data/local/bin/olsrd
data/local/etc/olsrd.conf
data/local/lib/
data/local/lib/olsrd_bmf.so.1.5.3
data/local/lib/olsrd_httpinfo.so.0.1
data/local/lib/olsrd_secure.so.0.5
data/local/lib/olsrd_mini.so.0.1
data/local/lib/olsrd_watchdog.so.0.1
data/local/lib/olsrd_dyn_gw_plain.so.0.4
data/local/lib/olsrd_dot_draw.so.0.3
data/local/lib/olsrd_tas.so.0.1
data/local/lib/olsrd_txtinfo.so.0.1
data/local/lib/olsrd_quagga.so.0.2.2

You might have to edit the /data/local/etc/olsrd.conf. This is what mine looks like:

# olsr.org OLSR daemon config file
# Lines starting with a # are discarded
# This file was shipped with the debian olsrd package
# This file is an example of a typical
# configuration for a mostly static
# network(regarding mobility) using
# the LQ extention
# Debug level(0-9)
# If set to 0 the daemon runs in the background
DebugLevel 0
# Interfaces and their rules
# Omitted options will be set to the
# default values. Multiple interfaces
# can be specified in the same block
# and multiple blocks can be set.
# !!CHANGE THE INTERFACE LABEL(s) TO MATCH YOUR INTERFACE(s)!!
# (eg. wlan0 or eth1):
#
# this is (in most cases) the only configuration you need to change
#Interface "eth1" "eth0" "wlan0" "wlan1" "ath0" "ath1"
Interface "wlan0"
{
# IPv4 broadcast address to use. The
# one usefull example would be 255.255.255.255
# If not defined the broadcastaddress
# every card is configured with is used
Ip4Broadcast 255.255.255.255
# IPv6 address scope to use.
# Must be 'site-local' or 'global'
# Ip6AddrType site-local
# IPv6 multicast address to use when
# using site-local addresses.
# If not defined, ff05::15 is used
# Ip6MulticastSite ff05::11
# IPv6 multicast address to use when
# using global addresses
# If not defined, ff0e::1 is used
# Ip6MulticastGlobal ff0e::1
# Emission intervals.
# If not defined, RFC proposed values will
# be used in most cases.
# Hello interval in seconds(float)
HelloInterval 6.0
# HELLO validity time
HelloValidityTime 600.0
# TC interval in seconds(float)
TcInterval 0.5
# TC validity time
TcValidityTime 300.0
# MID interval in seconds(float)
MidInterval 10.0
# MID validity time
MidValidityTime 300.0
# HNA interval in seconds(float)
HnaInterval 10.0
# HNA validity time
HnaValidityTime 300.0
# When multiple links exist between hosts
# the weight of interface is used to determine
# the link to use. Normally the weight is
# automatically calculated by olsrd based
# on the characteristics of the interface,
# but here you can specify a fixed value.
# Olsrd will choose links with the lowest value.
# Weight 0
# If a certain route should be preferred
# or ignored by the mesh, the Link Quality
# value of a node can be multiplied with a factor
# entered here. In the example the route
# using 192.168.0.1 would rather be ignored.
# A multiplier of 0.5 will result in a small
# (bad) LinkQuality value and a high (bad)
# ETX value.
# LinkQualityMult 192.168.0.1 0.5
# This multiplier applies to all other nodes
# LinkQualityMult default 0.8
}
# Fisheye mechanism for TC messages 0=off, 1=on
LinkQualityFishEye 1
# ignore topology information from nodes further than 3 hops away
#
# update topology information every 3.0 seconds
# (on slower embedded hardware with more than 100 nodes use something like 9 sec)
#
#LinkQualityDijkstraLimit 3 3.0
# IP version to use (4 or 6)
IpVersion 4
# Clear the screen each time the internal state changes
ClearScreen yes
# HNA IPv4 routes
# syntax: netaddr netmask
# Example Internet gateway:
# 0.0.0.0 0.0.0.0
Hna4
{
# Internet gateway:
# 0.0.0.0 0.0.0.0
# more entries can be added:
# 192.168.1.0 255.255.255.0
}
# HNA IPv6 routes
# syntax: netaddr prefix
# Example Internet gateway:
Hna6
{
# Internet gateway:
# :: 0
# more entries can be added:
# fec0:2200:106:: 48
}
# Should olsrd keep on running even if there are
# no interfaces available? This is a good idea
# for a PCMCIA/USB hotswap environment.
# "yes" OR "no"
AllowNoInt yes
# TOS(type of service) value for
# the IP header of control traffic.
# If not set it will default to 16
#TosValue 16
# The fixed willingness to use(0-7)
# If not set willingness will be calculated
# dynamically based on battery/power status
# if such information is available
Willingness 7
# Allow processes like the GUI front-end
# to connect to the daemon.
IpcConnect
{
# Determines how many simultaneously
# IPC connections that will be allowed
# Setting this to 0 disables IPC
MaxConnections 0
# By default only 127.0.0.1 is allowed
# to connect. Here allowed hosts can
# be added
Host 127.0.0.1
#Host 10.0.0.5
# You can also specify entire net-ranges
# that are allowed to connect. Multiple
# entries are allowed
#Net 192.168.1.0 255.255.255.0
}
# Wether to use hysteresis or not
# Hysteresis adds more robustness to the
# link sensing but delays neighbor registration.
# Used by default. 'yes' or 'no'
# Do not use hysteresis with ETX!
UseHysteresis no
# Hysteresis parameters
# Do not alter these unless you know
# what you are doing!
# Set to auto by default. Allowed
# values are floating point values
# in the interval 0,1
# THR_LOW must always be lower than
# THR_HIGH.
#HystScaling 0.50
#HystThrHigh 0.80
#HystThrLow 0.30
# Link quality level
# 0 = do not use link quality
# 1 = use link quality for MPR selection
# 2 = use link quality for MPR selection and routing
# Defaults to 0
LinkQualityLevel 2
# Link quality window size
# Defaults to 10
#LinkQualityWinSize 100
# Polling rate in seconds(float).
# Default value 0.05 sec
Pollrate 0.1
# TC redundancy
# Specifies how much neighbor info should
# be sent in TC messages
# Possible values are:
# 0 - only send MPR selectors
# 1 - send MPR selectors and MPRs
# 2 - send all neighbors
#
# defaults to 0
TcRedundancy 2
# MPR coverage
# Specifies how many MPRs a node should
# try select to reach every 2 hop neighbor
#
# Can be set to any integer >0
#
# defaults to 1
MprCoverage 5

Update: Remount the /system partition read-only:

shell@android:# mount -o remount,ro /system

Updated (order): To join an olsr mesh network, it’s important to forward other people’s traffic. Make sure that your kernel has ip forwarding enabled and that iptables allows forwarding, too.

echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -A FORWARD -j ACCEPT

Start olrsd with the following command:

/data/local/bin/olsrd

Check for results in your routing table using „route -n“. It may take a few minutes until your routing table is filled. (In case of doubt use „ps“ (not „ps aux“) to check if olsrd is running.)

To join an olsr mesh network, it’s important to forward other people’s traffic. Make sure that your kernel has ip forwarding enabled and that iptables allows forwarding, too.

 

echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -A FORWARD -j ACCEPT

Update: If you see routes executing „route -n“ but you can’t ping anything a reason might be that the wireless network configuration needs to be given the freifunk BSSID 02:CA:FF:EE:BA:BE. I recommend the free (as in freedom) app „WiFi ACE“ (WiFi Advanced Configuration Editor). Try to set the BSSID with this app. Update 2: If you don’t have the „route“ command on your phone, use „ip route show“.

So, I have my mobile freifunk router with me! Happy meshing!