Guerrilla VoIP

From Hackerspace ACKspace
Revision as of 16:52, 23 April 2015 by Xopr (talk | contribs) (added power (wattage) values)
Jump to: navigation, search
Project: Guerrilla VoIP
Featured:
State Active
Members xopr
GitHub No GitHub project defined. Add your project here.
Description low cost communication node
Picture
No project picture! Fill in form Picture or Upload a jpeg here

synopsis

Create a low cost communication node (with VoIP as a base), trying to connect as many as possible types of links, for example:

  • copper/fibre/WiFi network
  • DECT/POTS telephony
  • SIP/SCCP
  • HAM radio (or preferrably, CB radio: 27MC/PMR)
  • copper/WiFi/USB uplink


It also could need some of the following functionality:

  • PoE service (to drive phones, remote switches/accesspoints)
  • battery supported/powered (in case of power failures/lack of power)
  • Efficient power converter(s) when running on battery
  • sturdy compact waterproof casing

prototyping

So to make the first prototype, I chose the following:

  • ammo box
  • 7Ah battery
  • step-down converter 12->5V
  • step-up converter 12v->48V
  • Fritz!Box 7270 (NAT, FxS, FxO, DECT)
  • two Raspberry Pis running FreeSWITCH (external queue, internal SCCP server), DHCP and TFTP
  • Netgear GS110TP (8xPoE + 2xSFP)

Some power tests

hardware power source U I Papproximated
two Raspberry Pis, step down drill battery pack 12.6V[1] 330mA 2×2W
Cisco CP7940, step up drill battery pack 12.6V[1] 360mA - 450mA 5W
Fritz!box (wifi off), direct lab power supply 12V 360mA (idle) - 440mA
(42% - 52%, top ~880mA)
4.3W - 5.3W
15V 250mA (idle) 3.8W
Netgear GS110TP PoE, step up lab power supply 12V 330mA 4W
Netgear GS110TP PoE +
Cisco CP7940, step up
lab power supply 12V 740mA 9W
Complete set: 2 RasPis,
Fritz!box, switch,
phone + cellphone charging
lab power supply 12V 2000mA 24W
13.8V 1600mA 22W
cellphone charging lab power supply 5W[2]
Minimal setup:
(router+switch+Pi+phone)
16W[3]
[1] Approximated by calculating deviation from the lab power supply combined values, which was about 5% off 12V
[2] Approximated by subtracting all calculated items from the complete setup
[3] Approximated by just adding up individual items

interesting facts

  • Fritz!box has a switching regulator to 5V tested between 5.5V and 15V (drops off at 5.3V idle and elco at power supply segment is rated 16V)
  • PoE hack adapter connected pin 1 (white-orange) and pin 3 (white-green) with 22K resistor.
  • if the pre-standard CP-79x0 is connected using the PoE adapter hack, the Netgear GS110TP doesn't power, when you unplug it, it will enable power within 5 seconds; plug in, and the phone boots.
  • if you configure the administrative VLAN, the phone will fetch a DHCP lease on that VLAN, allowing you to seperately set up dnsmasq on a Raspberry Pi

done

  • the first version works, but still needs some manual labor
  • Telephone system:Cisco PoE hack cable
  • Cisco NL dialplan
  • tested with battery; float charging device still has to be made (haven't measured how long it would run on a single charge though, but enough time to do some important phone calling)

Also, I've been playing with the Banana Pi, since the Raspberry Pi sometimes chokes on input digits. Here is a log/some steps to reproduce

get the basics

apt-get install vlan dnsmasq make curl

create and install FreeSWITCH

see https://freeswitch.org/confluence/display/FREESWITCH/Debian#Debian-BuildingFromSource

cd /usr/src
curl https://freeswitch.org/stash/projects/FS/repos/freeswitch/browse/build/Makefile.centos6?raw > Makefile

If you want to compile and install STABLE branch, edit the above Makefile and add " -b v1.4 " just after the word "clone".

make && make install
  • (you can kill time by doing the other chapters)

create user 'freeswitch', add it to group 'daemon' and change owner and group of the freeswitch installation

cd /usr/local
adduser --disabled-password  --quiet --system --home /usr/local/freeswitch --gecos "FreeSWITCH Voice Platform" --ingroup daemon freeswitch
chown -R freeswitch:daemon /usr/local/freeswitch/
chmod -R ug=rwX,o= /usr/local/freeswitch/
chmod -R u=rwx,g=rx /usr/local/freeswitch/bin/*

prepare VLAN

modprobe 8021q
lsmod | grep 8021q
echo 8021q >> /etc/modules
vconfig set_name_type DEV_PLUS_VID_NO_PAD

set-up network and VLAN

vi /etc/network/interfaces
auto lo
iface lo inet loopback

auto eth0

# dhcp configuration, used in normal operation (this connects to your internet)
iface eth0 inet dhcp

# static ip configuration, used for stand-alone preconfiguring factory-reset phones
#iface eth0 inet static
#	address 192.168.6.1
#	netmask 255.255.255.0
#	gateway 192.168.6.1

# operational VLAN 11 (pick any), for usage with VoIP
auto eth0.11
iface eth0.11 inet static
    address 192.168.11.1
    netmask 255.255.255.0
    vlan-raw-device eth0

dnsmasq

vi /etc/dnsmasq.conf
# uncomment to enable dhcp server on eth0, used for stand-alone preconfiguring factory-reset phones
#interface=eth0
# operational VLAN 11 (pick any), for usage with VoIP
interface=eth0.11

# Choose different ranges for each (V)LAN
dhcp-range=eth0,192.168.6.50,192.168.6.150,12h
dhcp-range=eth0.11,192.168.11.50,192.168.11.150,12h

# Most likeley not needed
#option:tftp-server
#dhcp-option=66,192.168.6.1
#option:
#dhcp-option=150,192.168.178.16

# Enable dnsmasq's built-in TFTP server to serve config files
enable-tftp

# Set the root directory for files available via FTP.
tftp-root=/srv/tftp

Create the /srv/tftp directory and put the configs and firmwares in it. Here is a config generator you can put in there (sorry, can't provide the firmwares since "I don't have them").

service dnsmasq restart

or

/etc/init.d/dnsmasq restart

toggleconfig script

#!/bin/bash

restart_services()
{
  trap -- SIGHUP SIGINT SIGTERM

  service dnsmasq stop > /dev/null
  #nohup sh -c "invoke-rc.d networking stop; sleep 2; invoke-rc.d networking start"
  invoke-rc.d networking stop > /dev/null
  sleep 2
  invoke-rc.d networking start > /dev/null
  service dnsmasq start > /dev/null

  trap clean_up SIGHUP SIGINT SIGTERM
}

clean_up()
{
  # reset gpio pin and led
  echo "11" > /sys/class/gpio/unexport
  echo 0 > /sys/class/leds/led0/brightness
  echo none > /sys/class/leds/led0/trigger

  echo done
  exit
}

if [ ! -f /etc/dnsmasq.conf.regular ]; then echo "/etc/dnsmasq.conf.regular does not exist"; exit; fi
if [ ! -f /etc/dnsmasq.conf.config ]; then echo "/etc/dnsmasq.conf.config does not exist"; exit; fi
if [ ! -f /etc/network/interfaces.regular ]; then echo "/etc/network/interfaces.regular does not exist"; exit; fi
if [ ! -f /etc/network/interfaces.config ]; then echo "/etc/network/interfaces.config does not exist"; exit; fi

trap clean_up SIGHUP SIGINT SIGTERM

echo "11" > /sys/class/gpio/export
echo "in" > /sys/class/gpio/gpio11/direction

while true; do

  echo "regular mode"
  echo none > /sys/class/leds/led0/trigger

  # regular config files
  cp /etc/dnsmasq.conf.regular /etc/dnsmasq.conf
  cp /etc/network/interfaces.regular /etc/network/interfaces

  restart_services

  while [ `cat /sys/class/gpio/gpio11/value` -gt 0 ]; do
    echo 1 > /sys/class/leds/led0/brightness
    sleep 0.05
    echo 0 > /sys/class/leds/led0/brightness
    sleep 3
  done

  echo "config mode"
  echo "heartbeat" > /sys/class/leds/led0/trigger

  # regular config files
  cp /etc/dnsmasq.conf.config /etc/dnsmasq.conf
  cp /etc/network/interfaces.config /etc/network/interfaces

  restart_services

  while [ `cat /sys/class/gpio/gpio11/value` -le 0 ]; do sleep 3; done

done

preconfigure phone

  • Connect the phone directly using a (optionally crosslink) ethernet cable.
  • Power the phone, and hold # until the red (mute) light is off and the phone states: "Reset sequence detected"
  • type 123456789*0#, and when asked to keep network config, choose 2=no
  • once the new firmware is loaded (Freeswitch is not running, so it won't connect), press 'settings' (checkbox button at the bottom right)
  • go to Admin. VLAN ID
  • type **# to unlock the setting, and press 'edit'
  • type in your voice VLAN (11 like the configs say)
  • press validate, and save
  • dnsmasq and interfaces configs can now be restored (no dhcp on eth0, only eth0.11)
  • nohup sh -c "invoke-rc.d networking stop; sleep 2; invoke-rc.d networking start"

todo

  • work out 'modus operandi': multiple config files switchable by phone
  • work on dual linux config with GPIO hardware switch
  • test the fibre ports
  • add homeplug as a proof of concept
  • design and create (or buy) small-sized float charger (13.8V 2A) with overcurrent protection, if needed