diff --git a/conf/system/olsrd/olsrd.conf b/conf/system/olsrd/olsrd.conf new file mode 100644 index 0000000000..ad7fdd1eb3 --- /dev/null +++ b/conf/system/olsrd/olsrd.conf @@ -0,0 +1,330 @@ +# +# olsr.org OLSR daemon config file +# +# Lines starting with a # are discarded +# +# This file was shipped with the debian olsrd package +# + +# Debug level(0-9) +# If set to 0 the daemon runs in the background + +DebugLevel 0 + +# the interface the mesh runs on is specified at run time using the -i flag + +InterfaceDefaults +{ + # Olsrd can autodetect changes in NIC configurations (IP address + # changes etc.). This is enabled by default and the interval to + # poll for changes on is defined by NicChgsPollInt. This polling + # can be disabled pr. NIC by setting AutoDetectChanges to no. + + #AutoDetectChanges no + + # 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 192.168.1.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 0.1 + + # HELLO validity time + HelloValidityTime 1.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 +} + +## these settings should work for funkfeuer, freifunk, etc. +# Fisheye mechanism for TC messages 0=off, 1=on +LinkQualityFishEye 1 +LinkQualityAlgorithm "etx_ff" + +## if using commotionwireless.net, comment the line above and uncomment these: +#LinkQualityFishEye 0 +#LinkQualityAlgorithm "etx_ffeth" + +# 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 3 + +# 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 1 + + # 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 + +# 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 + + +# Olsrd plugins to load +# This must be the absolute path to the file +# or the loader will use the following scheme: +# - Try the paths in the LD_LIBRARY_PATH +# environment variable. +# - The list of libraries cached in /etc/ld.so.cache +# - /lib, followed by /usr/lib + +# Configuration examples for plugins: +# see /usr/share/doc/olsrd-plugins/ for some for documentation + +# these are loaded from LD_LIBRARY_PATH +#LoadPlugin "olsrd_httpinfo.so.0.1" +#{ + # defaults to 1978 + #PlParam "Port" "8080" + # if you dont set these, the default is to listen only on the loopback device + #PlParam "Host" "80.23.53.22" + #PlParam "Net" "10.0.0.0 255.0.0.0" + #PlParam "Net" "0.0.0.0 0.0.0.0" + #PlParam "Host" "127.0.0.1" +#} + +## for more info: http://olsr.org/?q=txtinfo_plugin +#LoadPlugin "olsrd_txtinfo.so.0.1" +#{ +# PlParam "port" "2006" +# PlParam "accept" "0.0.0.0" +#} + +## for more info: http://olsr.org/?q=jsoninfo_plugin +#LoadPlugin "olsrd_jsoninfo.so.0.0" +#{ +# PlParam "port" "9090" +# PlParam "accept" "0.0.0.0" +#} + +# useful if your machine has an uplink +#LoadPlugin "olsrd_dyn_gw.so.0.4" +#{ + # Here parameters are set to be sent to the + # plugin. Theese are on the form "key" "value". + # Parameters ofcause, differs from plugin to plugin. + # Consult the documentation of your plugin for details. + + # Example: dyn_gw params + + # how often to check for Internet connectivity + # defaults to 5 secs + #PlParam "Interval" "40" + + # if one or more IPv4 addresses are given, do a ping on these in + # descending order to validate that there is not only an entry in + # routing table, but also a real internet connection. If any of + # these addresses could be pinged successfully, the test was + # succesful, i.e. if the ping on the 1st address was successful,the + # 2nd won't be pinged + #PlParam "Ping" "141.1.1.1" + #PlParam "Ping" "194.25.2.129" +#} + +#LoadPlugin "olsrd_nameservice.so.0.2" +#{ + #PlParam "name" "xxx" + #PlParam "a.b.c.d" "xxx-eth" + #PlParam "a.b.c.e" "xxx-bbb" + #PlParam "a.b.c.f" "xxx-olsr" + #PlParam "suffix" ".olsr" +#} + +#LoadPlugin "olsrd_dot_draw.so.0.3" +#{ + # accept connection from IP: + # default 127.0.0.1 (localhost) + #PlParam "accept" "192.168.0.5" + #PlParam "port" "2004" +#} + + diff --git a/sw/tools/parrot/ardrone2.py b/sw/tools/parrot/ardrone2.py index 466c7812d2..b97a8e9f93 100755 --- a/sw/tools/parrot/ardrone2.py +++ b/sw/tools/parrot/ardrone2.py @@ -122,6 +122,17 @@ def ardrone2_install_network_script(): print(parrot_utils.execute_command(tn,"mv /data/video/wifi_setup.sh /bin/wifi_setup.sh")) print(parrot_utils.execute_command(tn,"chmod 777 /bin/wifi_setup.sh")) +# Install olsr deamon +def ardrone2_install_olsrd(): + print('Uploading olsr deamon') + parrot_utils.uploadfile(ftp, "olsrd", file("ardrone2/olsrd", "rb")) + parrot_utils.uploadfile(ftp, "olsrd.conf", file("ardrone2/olsrd.conf", "rb")) + print(parrot_utils.execute_command(tn,"mv /data/video/olsrd /bin/olsrd")) + print(parrot_utils.execute_command(tn,"chmod 777 /bin/olsrd")) + print(parrot_utils.execute_command(tn,"mkdir -p /etc/olsrd")) + print(parrot_utils.execute_command(tn,"mv /data/video/olsrd.conf /etc/olsrd")) + print(parrot_utils.execute_command(tn,"rm -f /var/run && ln -s /tmp /var/run")) # olsrd needs /var/run folder, symlinked to /tmp + # Set network SSID def ardrone2_set_ssid(name): write_to_config('ssid_single_player', name) @@ -136,7 +147,7 @@ def ardrone2_set_ip_address(address): # Set wifi mode (0: master, 1: ad-hoc, 2: managed, *: master) def ardrone2_set_wifi_mode(mode): - modes = { 'master' : '0', 'ad-hoc' : '1', 'managed' : '2' } + modes = { 'master' : '0', 'ad-hoc' : '1', 'managed' : '2', 'ad-hoc-olsr' : '3' } try: val = modes[mode] except: @@ -145,6 +156,11 @@ def ardrone2_set_wifi_mode(mode): write_to_config('wifi_mode', val) print('The Wifi mode of the ARDrone2 is changed to ' + mode + ' (' + val + ')') +# Set network channel +def ardrone2_set_wifi_channel(chan): + write_to_config('wifi_channel', chan) + print('The network channel of the ARDrone 2 is changed to ' + chan) + def ardrone2_status(): config_ini = parrot_utils.execute_command(tn,'cat /data/config.ini') @@ -224,7 +240,8 @@ subparser_wifimode.add_argument('mode', help='the new Wifi mode', choices=['mast subparser_configure_network = subparsers.add_parser('configure_network', help='Configure the network on the ARDrone 2') subparser_configure_network.add_argument('name', help='the new network ID(SSID)') subparser_configure_network.add_argument('address', help='the new IP address') -subparser_configure_network.add_argument('mode', help='the new Wifi mode', choices=['master', 'ad-hoc', 'managed']) +subparser_configure_network.add_argument('mode', help='the new Wifi mode', choices=['master', 'ad-hoc', 'managed', 'ad-hoc-olsr']) +subparser_configure_network.add_argument('--channel', help='the wifi channel (auto or 1 to 11)', default='auto') subparser_install_autostart = subparsers.add_parser('install_autostart', help='Install custom autostart script and set what to start on boot for the ARDrone 2') subparser_install_autostart.add_argument('type', choices=['native', 'paparazzi_raw', 'paparazzi_sdk'], help='what to start on boot') @@ -285,6 +302,7 @@ elif args.command == 'configure_network': print('Host:\t\t' + args.host + ' (' + read_from_config('static_ip_address_base', config_ini) + read_from_config('static_ip_address_probe', config_ini) + ' after boot)') print('Mode:\t\t' + read_from_config('wifi_mode', config_ini)) + print('Channel:\t' + read_from_config('wifi_channel', config_ini)) print('=============================') if check_wifi_setup(): print('Custom Wifi script already installed') @@ -293,15 +311,19 @@ elif args.command == 'configure_network': else: if raw_input("Shall I install custom Wifi script (recommanded) (y/N) ").lower() == 'y': ardrone2_install_network_script() + if raw_input("Shall I install olsrd (ad-hoc wireless mesh routing deamon) (y/N) ").lower() == 'y': + ardrone2_install_olsrd() ardrone2_set_ssid(args.name) ardrone2_set_ip_address(args.address) ardrone2_set_wifi_mode(args.mode) + ardrone2_set_wifi_channel(args.channel) config_ini = parrot_utils.execute_command(tn,'cat /data/config.ini') print('== New network setup after boot ==') print('Network id:\t' + read_from_config('ssid_single_player', config_ini)) print('Host:\t\t' + read_from_config('static_ip_address_base', config_ini) + read_from_config('static_ip_address_probe', config_ini)) print('Mode:\t\t' + read_from_config('wifi_mode', config_ini)) + print('Channel:\t' + read_from_config('wifi_channel', config_ini)) print('==================================') if raw_input("Shall I restart the ARDrone 2? (y/N) ").lower() == 'y': diff --git a/sw/tools/parrot/ardrone2/olsrd b/sw/tools/parrot/ardrone2/olsrd new file mode 100755 index 0000000000..c2127d439f Binary files /dev/null and b/sw/tools/parrot/ardrone2/olsrd differ diff --git a/sw/tools/parrot/ardrone2/olsrd.conf b/sw/tools/parrot/ardrone2/olsrd.conf new file mode 100644 index 0000000000..f9ad07047c --- /dev/null +++ b/sw/tools/parrot/ardrone2/olsrd.conf @@ -0,0 +1,214 @@ +# +# OLSR.org routing daemon config file +# This file contains the necessary config options +# for an RFC compatible mesh +# (for other options see olsrd.conf.default.full) +# +# Lines starting with a # are discarded +# + +#### ATTENTION for IPv6 users #### +# Because of limitations in the parser IPv6 addresses must NOT +# begin with a ":", so please add a "0" as a prefix. + +########################### +### Basic configuration ### +########################### +# keep this settings at the beginning of your first configuration file + +# Debug level (0-9) +# If set to 0 the daemon runs in the background, unless "NoFork" is set to true +# (Default is 1) + +DebugLevel 0 + +# IP version to use (4 or 6) +# (Default is 4) + +# IpVersion 4 + +################################# +### OLSRd agent configuration ### +################################# +# this parameters control the settings of the routing agent which are not +# related to the OLSR protocol and it's extensions + +# FIBMetric controls the metric value of the host-routes OLSRd sets. +# - "flat" means that the metric value is always 2. This is the preferred value +# because it helps the linux kernel routing to clean up older routes +# - "correct" use the hopcount as the metric value. +# - "approx" use the hopcount as the metric value too, but does only update the +# hopcount if the nexthop changes too +# (Default is "flat") + +# FIBMetric "flat" + +####################################### +### Linux specific OLSRd extensions ### +####################################### +# these parameters are only working on linux at the moment, but might become +# useful on BSD in the future + +# Activates (in IPv6 mode) the automatic use of NIIT +# (see README-Olsr-Extensions) +# (default is "yes") + +UseNiit no + +# Activates the smartgateway ipip tunnel feature. +# See README-Olsr-Extensions for a description of smartgateways. +# (default is "yes") + +SmartGateway no + +############################## +### OLSR protocol settings ### +############################## + +# For testing purposes it may be nice to use another port for olsrd +# for using another port than the IANA assigned one +# for a production network, there should be a good reason!! +# valid values are integers >1, please be careful with using reserved +# port numbers +# (default is 698, the IANA assigned olsr-port) + +# OlsrPort 698 + +# The fixed willingness to use (0-7) +# If not set willingness will be calculated +# dynamically based on battery/power status +# (default is 3) + +# Willingness 3 + +# HNA (Host network association) allows the OLSR to announce +# additional IPs or IP subnets to the net that are reachable +# through this node. +# Syntax for HNA4 is "network-address network-mask" +# Syntax for HNA6 is "network-address prefix-length" +# (default is no HNA) +Hna4 +{ +# Internet gateway +# 0.0.0.0 0.0.0.0 +# specific small networks reachable through this node +# 15.15.0.0 255.255.255.0 +} +Hna6 +{ +# Internet gateway +# 0:: 0 +# specific small networks reachable through this node +# fec0:2200:106:0:0:0:0:0 48 +} + +# Hysteresis for link sensing (only for hopcount metric) +# Hysteresis adds more robustness to the link sensing +# but delays neighbor registration. +# (defaults to yes) + +# UseHysteresis yes + +# Hysteresis parameters (only for hopcount metric) +# 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!! +# (default is 0.5/0.8/0.3) + +# HystScaling 0.50 +# HystThrHigh 0.80 +# HystThrLow 0.30 + +# TC redundancy +# Specifies how much neighbor info should be sent in +# TC messages. Because of a design problem in the 0.5.x +# dijkstra implementation this value must be set to 2. +# 2 - send all neighbors +# (default is 2) + +# TcRedundancy 2 + +# MPR coverage specifies how many MPRs a node should +# try select to reach every 2 hop neighbor. Because of +# a design problem in the 0.5.x dijkstra algorithm this +# value should be set to 7. +# (default is 7) + +# MprCoverage 7 + +################################ +### OLSR protocol extensions ### +################################ + +# Link quality level switch between hopcount and +# cost-based (mostly ETX) routing. Because of +# a design problem in the 0.5.x dijkstra algorithm this +# value should not be set to 1. +# 0 = do not use link quality +# 2 = use link quality for MPR selection and routing +# (default is 2) + +LinkQualityLevel 2 + +LinkQualityAlgorithm "etx_ff" + +# Fisheye mechanism for TCs (0 meansoff, 1 means on) +# (default is 1) + +LinkQualityFishEye 0 + +##################################### +### Example plugin configurations ### +##################################### +# Olsrd plugins to load +# This must be the absolute path to the file +# or the loader will use the following scheme: +# - Try the paths in the LD_LIBRARY_PATH +# environment variable. +# - The list of libraries cached in /etc/ld.so.cache +# - /lib, followed by /usr/lib +# +# the examples in this list are for linux, so check if the plugin is +# available if you use windows/BSD. +# each plugin should have a README file in it's lib subfolder + +# LoadPlugin "olsrd_txtinfo.dll" +#LoadPlugin "olsrd_txtinfo.so.0.1" +#{ + # the default port is 2006 but you can change it like this: + #PlParam "port" "8080" + + # You can set a "accept" single address to allow to connect to + # txtinfo. If no address is specified, then localhost (127.0.0.1) + # is allowed by default. txtinfo will only use the first "accept" + # parameter specified and will ignore the rest. + + # to allow a specific host: + #PlParam "accept" "172.29.44.23" + # if you set it to 0.0.0.0, it will accept all connections + #PlParam "accept" "0.0.0.0" +#} + +###################################### +### OLSRd Interfaces configuration ### +###################################### +# multiple interfaces can be specified for a single configuration block +# multiple configuration blocks can be specified + +# WARNING, don't forget to insert your interface names here ! +Interface "ath0" +{ + # Emission intervals in seconds. + # If not defined, Freifunk network defaults are used + # (default is 2.0/20.0 for Hello and 5.0/300.0 for Tc/Mid/Hna) + + # HelloInterval 2.0 + # HelloValidityTime 6.0 + # TcInterval 5.0 + # TcValidityTime 30.0 + # MidInterval 5.0 + # MidValidityTime 30.0 + # HnaInterval 5.0 + # HnaValidityTime 30.0 +} diff --git a/sw/tools/parrot/ardrone2/wifi_setup.sh b/sw/tools/parrot/ardrone2/wifi_setup.sh index a1e075d98d..a342e07916 100755 --- a/sw/tools/parrot/ardrone2/wifi_setup.sh +++ b/sw/tools/parrot/ardrone2/wifi_setup.sh @@ -20,6 +20,9 @@ export ATH_MODULE_ARGS="ifname=$NETIF" WIFI_MODE=`grep wifi_mode /data/config.ini | awk -F "=" '{ gsub(/ */,"",$2); print $2}'` +# ad-hoc wireless mesh routing daemon disabled by default +OLSR=false + case $WIFI_MODE in 0) WIFI_MODE=master @@ -30,6 +33,10 @@ case $WIFI_MODE in 2) WIFI_MODE=managed ;; +3) + WIFI_MODE=ad-hoc + OLSR=true + ;; *) WIFI_MODE=master ;; @@ -84,7 +91,17 @@ SSID=ardrone2_wifi echo "SSID=\"$SSID\"" fi +RANDOM_CHAN=`grep wifi_channel /data/config.ini | awk -F "=" '{print $2}'` +RANDOM_CHAN=`echo $RANDOM_CHAN` +# Default random channel +if [ -n "$RANDOM_CHAN" ] +then +echo "RANDOM_CHAN=$RANDOM_CHAN" +else +#default RANDOM_CHAN. RANDOM_CHAN=auto +echo "RANDOM_CHAN=\"$RANDOM_CHAN\"" +fi echo "Creating $WIFI_MODE Network $SSID" @@ -181,11 +198,17 @@ echo $MAC_ADDR `date` `/bin/random_mac` > /dev/urandom telnetd -l /bin/sh # Check if not booting in master mode -if [ "$WIFI_MODE" != "managed" ] +if [ "$WIFI_MODE" != "managed" ] && [ "$OLSR" != "true" ] then udhcpd /tmp/udhcpd.conf fi +# Check OLSR deamon should be started +if [ "$OLSR" = "true" ] && [ -f "/bin/olsrd" ] && [ -f "/etc/olsrd/olsrd.conf" ] +then + olsrd +fi + # Adding route for multicast-packet route add -net 224.0.0.0 netmask 240.0.0.0 dev $NETIF