HOWTO: Role Playing Game with Phones using Asterisk and other FLOSS

Problem Description

This HOWTO describes, in the context of a role playing game, a set of four phones used by the players for communication during the game. The game takes place in a hotel or a conference center and the players are in two separate rooms. When the players arrive at their location, the recording phones are plugged in and tested. The game duration is six hours maximum. There is no cable connection between the two rooms.

Each conversation is recorded in separate timestamped files and are available in real time, on a file system or through a standard networked protocol. The phones are never used for conferences between more than two phones.

The hardware and software solution is designed to work simply and reliably. The installation does not require a technical person and the probability of a malfunction within one game session is less than 1 time out of 10.

The key details presented in this HOWTO are:

  • The hardware that should be acquired (phones and computer to store the recordings and network the site), which software should be installed and which software needs to be developed to glue the solution together.
  • A description of how to use the solution created, from installation to putting the hardware back in a box. The user is assumed to be completely clueless as to how the technology works.

Hardware Recommendations

This section describes which hardware should be used to set up the game.

One Box in Each Room?

A key requirement here is that "there is no cable connection between the two rooms". This makes wireless routers a key component in the system, and as such, the strong inclination for an Asterisk hacker will be to use the wireless router itself as the Asterisk server. The process for doing so is talked about in many places, including this wiki. However, I do not recommend this solution in this particular case, for the following reasons:

  • The boxes are not particularly powered, and doing full recording of the game might have gaps, and/or cause slowdown of the networks.
  • Configuration and installation of Asterisk is much more difficult on these boxes, and often the latest version of Asterisk is not available.
  • The boxes do not have enough memory without serious hacks (to make SD card attachment possible) to hold the recordings for the full event easily.

Server Boxes

This leaves basically two options: (a) buy a larger full-fledged computer capable of being both the wireless router and the Asterisk instance, or (b) buy separate wireless router and Asterisk servers.

Option (a) is appealing, but if your goal is to keep the bulkiness of the hardware to a minimal, this can simply be courting disaster. The reason is that the small boxes that I plan recommend for this task use laptop-style components, and can be flakey when you mix-and-match two many tasks at once. Therefore, I am recommend the solution of (b).

I mentioned a number of small boxes that are on the market. Linux devices has a somewhat out-of-date page devoted to them. It has become clear that this is a difficult market to survive in, as the prices are a bit high for most people and meanwhile, the arm-based wireless routers are so cheap. The number of boxes on Linux Devices' list that are no longer being sold is a clear example of this fact.

There is some discussion about Asterisk embedded systems, but many of those products too, are end-of-life, or are more of do-it-yourself kits.

I basically consider three vendors worth looking at. Soekris, Fit PC (from [ and the eBox PC (sold in the USA via WDL Systems and also reviewed directly Linux Devices).

Soekris primarily builds components that must be assembled. Unless you are into "doing it yourself", this is probably not a good option. Fit PC is an extremely interesting option, but it basically has only one specification option, so if that does not suit your needs, you can't go with this option. This is also Fit PC's first foray into this type of box, so I am skeptical.

This leaves the eBox, which is actually based on Soekris' board, and has a number of various options and configurations. Note that there is a [, but I have a strong belief that other models will work well.

For this task, I recommend the eBox-4800, which retails in the USA for a total of $429 — US$288 for system and US$141 for the 4GB embedded IDE flash. The 4GB should be more than enough room to do the operating system, Asterisk installation and the recording. (See below in the software section for details).

Thus, we buy two of these boxes, one for each room, at approximately US$429 each, totalling US$858.

Wireless Network

We now need to build a wireless network between the two rooms. I suggest buying an old standard, Linksys WRTG54GL. This wireless router is known to work well, and can run OpenWRT (discussed below in the software sections). It also is relatively cheap, at around US$50

One wireless router goes into each room, and plugs directly into each computer.

The new total is now US$958 for hardware. Let's assume we end up spending around US$1,060 once we buy network cable as needed and power strips for each room.

Hard Telephones

There are many VoIP telephones on the market. Many users rave about Grandstream as the cheapest phone that actually doesn't sound horrible. I have always simply purchased Polycom phones, because they are the most widely deployed and has sound quality that is unmatched.

In particular, I always prefer the Polycom Soundpoint IP 501. There are slightly cheaper models from Polycom; however, the 501 has a very good speaker phone for the price and a few other perks that make it easier to manage (in particular, it's slightly easier to upgrade the firmware).

These phones cost about US$170. Buying two would bring our grand total for hardware costs to $1,350. I am sure we could avoid exceeding that price for sure, particularly if we look for deals.

Final Shopping List

1 eBox 4800, w/ 4GB solid state IDE memory
4 Polycom 501
various network cabling as needed

Software Configuration

This section describes the basic installation and configuration of software once the equipment is purchased.

Wireless Network

Start with the software configuration of the wireless network, as this is the easiest and most straightforward part of the configuration. You can start by simply following the instructions on the OpenWRT Wiki for installing on the WRT54GL. Those instructions talk about installing White Russian, but I strongly recommend using Kamikaze (7.09), as that is the more stable and easier to configure distribution.

Access Point Router (DRM)

Once you have Kamikaze running on each router, one should be configured in the them to be a regular access point made for clients, and the other should be a base station. The access point should be configured something like this (files referred to are on the wireless boxes):

In /etc/config/wireless:

config wifi-device wl0
option type broadcom
option channel 4

config wifi-iface
option device wl0
option network lan
option mode ap
option ssid RolePlaying
option encryption none

In /etc/config/network:

config switch eth0
option vlan0 "0 1 2 3 5*"
option vlan1 "4 5"

config interface loopback
option ifname "lo"
option proto static
option ipaddr
option netmask

config interface lan
option type bridge
option ifname "eth0.0"
option proto static
option ipaddr
option netmask

config interface wan
option ignore 1

config route
option interface lan
option target
option netmask
option gateway

(i.e., Leave the WAN interface off.)

Make sure you are running a DHCP server, in/etc/config/dhcp:

config dhcp
option interface lan
option start 100
option limit 150
option leasetime 12h

config dhcp
option interface wan
option ignore 1

Station (VENTE LIEE)

Now, on the other device set it up as a station. I haven't done this in practice before, but it's talked about often on the forums:

In /etc/network/wireless:

config wifi-device wl0
option type broadcom
option disabled 0

config wifi-iface
option device wl0
option network wan
option mode sta
option ssid RolePlaying
option encryption none

In /etc/config/network:

config switch eth0
option vlan0 "0 1 2 3 5*"
option vlan1 "4 5"

config interface loopback
option ifname "lo"
option proto static
option ipaddr
option netmask

config interface lan
option type bridge
option ifname "eth0.0"
option proto static
option ipaddr
option netmask

config interface wan
option ifname wl0
option proto static
option ipaddr
option netmask

In /etc/config/dhcp:

config dhcp
option interface lan
option start 100
option limit 150
option leasetime 12h

config dhcp
option interface wan
option ignore 1

Warning; It missing some iptables rules for the sip and rtp working. For the moment /etc/init.d/firewall stop is ok.

chmod -x /etc/init.d/firewall

A note on NAT

BTW, I feel that this configuration is a bit more NAT than we need. In the second room, IP numbers will be in and the IP numbers in the main room will be in 10.5.53/24, and the routers will be and, respectively. There should be a way to simply bridge across the wireless network and serve IPs from from the main AP's DHCP server. I would suggest setting up this scenario with the extra NAT, make sure it works, then experiment with putting everything on the same network.

Perform full backup of openwrt-ap

rsync -avr --delete --exclude=/dev --exclude=/proc root@ openwrt-ap/
root@'s password: toor
tar cvzf openwrt-ap.tar.gz openwrt-ap/

Perform full backup of openwrt-station

rsync -avr --delete --exclude=/dev --exclude=/proc root@ openwrt-station/
root@'s password: toor
tar cvzf openwrt-station.tar.gz openwrt-station/

The Server: Initial Config

Now, you have plans to place a WRT54GL in each room, and should be able to setup network devices on the local hub and ping across to the other room. I won't mention network configuration details further, I'll assume that you've gotten the networks connected.

The server has ip : with gateway and netmask

Installing the Operating System

The easiest way to do operating system installation on the eBox's is via network install. The tutorial I find best is this one, which is geared toward Ubuntu but will surely work well for Debian as well. If you use Ubuntu, I suggest hardy or gutsy, because earlier distributions don't come with Asterisk 1.4.x (see below). For Debian, even etch still has 1.2.x, so you might have to use sid or backport a Asterisk 1.4.x package.

The Server: Asterisk Config

You can probably get away with using the Asterisk install that comes with the operating system you install. Many distributions are still on 1.2.x, which has some bugs and is not nearly as solid as 1.4. Therefore, I just don't recommend 1.2.x.


The config file for dialing in Asterisk is called the dialplan and kept in extensions.conf. This application won't need a particularly complicated dialplan. The configuration will look something like this, we'll call the local phone context "roleplaying" (I like to make default context empty at all times, which is why it is empty at the end). A sample file ended in "*.0.wav". The ".0" is unaccounted for in this configuration.


exten => 01,1,Ringing
exten => 01,n,Monitor(wav,conference-${CALLERID(num)}-${EXTEN}-${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)}-${UNIQUEID})
exten => 01,n,Dial(SIP/room01phone01, 10)

exten => 02,1,Ringing
exten => 02,n,Monitor(wav,conference-${CALLERID(num)}-${EXTEN}-${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)}-${UNIQUEID})
exten => 02,n,Dial(SIP/room01phone02, 10)

exten => 03,1,Ringing
exten => 03,n,Monitor(wav,conference-${CALLERID(num)}-${EXTEN}-${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)}-${UNIQUEID})
exten => 03,n,Dial(SIP/room02phone03, 10)

exten => 04,1,Ringing
exten => 04,n,Monitor(wav,conference-${CALLERID(num)}-${EXTEN}-${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)}-${UNIQUEID})
exten => 04,n,Dial(SIP/room02phone04, 10)

A few things to note about how this works:
  • All the recordings of the call happen via the Asterisk "application" (another word for "commands" in the dialplan): MixMonitor
  • It rings for 10 seconds (that's the 10 on the Dial application)
  • The Monitor application records each side of the conversation in separate files in case you prefer that.
  • The monitor files are usually kept in /var/spool/asterisk/monitor, although the path name can be changed in asterisk.conf.
  • The ssh root@ password is toor
  • I am using various dialplan variables to set the names of the files. The way I have it set up, it means they'll be named after the extension being called, the date and a unique id for the call. If you want to do something smarter, you can use other variables, or use an AGI script to call out to the system.


The sip.conf file is where the communication between the Polycom phones and the Asterisk server will be specified.


dtmfmode=rfc2833 ; Choices are inband, rfc2833, or info
callerid="Phone 01" <01>

Repeat a similar entry for the rest of the phones.

A few things to note:
  • The deny/permit can be adjusted for network needs.
  • disallow/allow is for codecs. For a fast network, ulaw is the best Free codec you can use.
  • progressinband and dtmfmode usually work set that way for polycoms, but change them if you need to.


UMASK=003 #instead of 007 for recorded files to be readable by all users

chmod +x /var/spool/asterisk
chmod +rx /var/spool/asterisk/monitor

Polycom Configuration

Polycoms that are made to be in a stable office environment are usually best configured by FTP and downloadable config files. However, you need only set a few things in this case, you you might as well do the configuration on the phone menu directly.

The only three items you should need to set are:

  1. The username, which is the thing in []'s from the sip.conf
  2. The password, which is the thing in the secret= field from the sip.conf
  3. The IP number of the SIP server, which is the IP number where Asterisk runs.

It's pretty straight-forward from the menus on how to set these, and they stay in programmable RAM even when you unplug the phones.

Make sure there is no packet-filtering firewall between the Polycom and the Asterisk server. You need both the UDP SIP port (5060) and the various RTP ports allowed through. If you can make a phone ring but can't hear anything, it's an RTP firewall or routing problem most of the time.

The default password for the interface web is : Polycom/456

Additional (Custom) Software

Presumably, after the event is over, the users will want to listen to what was said. I suggest writing a small web application that reads the files from the monitor directory and reconstructs who-called-who in some sort of nice interface, and allow the user to choose which one they'd like to hear.

Another option, if one wanted to be interesting, would be to play things using the default Asterisk prompts (or festival/espeak) that say things like "Phone 01 calls 02 at TIME for N MINUTES. Call follows." Then, says "Call Ends" at the end, followed by the next one. This would be one large file of audio for the whole game.

Note on Disk space

About a megabyte a minute is what you'll need, if you don't try to encode to a smaller format while running, but you'll still have plenty of space with 4GB.

Instructions for the User

It's a good idea to get color-coded Ethernet cable, so that every type of cable used from one place to another is a different color. These instructions are written assuming you have done so.

You should also label the router that goes in the main room as "MAIN ROUTER" and label the computer "COMPUTER". Label the second router "AUX ROUTER". Label the phones "01", "02", "03", and "04".

First Room

In this room, place the MAIN ROUTER and COMPUTER. There is a power supply for each.

Plug the blue Ethernet cables into phones "01" and "02", and plug the other end into the back of the MAIN ROUTER, in the main row of Ethernet ports. Do not yet plug in the telephones.

Plug the green Ethernet cable into the back of the computer, and plug the other end into the back of the MAIN ROUTER, in the main row of ports. Plug in power supplies for the COMPUTER and the MAIN ROUTER, and press the power button on the COMPUTER.

Two minutes later, plug the telephones in. This room will be ready when the phones come up to their main screen.

Second Room

In this room, place the AUX ROUTER and phones 03 and 04. There is a power supply for each.

Plug in the AUX ROUTER. Wait two minutes, and plug in phones 03 and 04. This room will be ready when the phones come up to their main screen.



The setup scales well with 4+2 phones.

adding call-limit=1 to each phone for limiting incoming call to one

extensions.conf, dialplan to dispatch 0234 extension to phone02 with role 34:

exten => _0[1-2]XX,1,Ringing
exten => _0[1-2]XX,n,AGI(/root/taranis.agi, ${EXTEN:2})
exten => _0[1-2]XX,n,Set(CALLERID(name)=${CALLERNAME})
exten => _0[1-2]XX,n,Set(MONITOR_EXEC=/root/rename_recording)
exten => _0[1-2]XX,n,Monitor(wav,${CALLERID(num)}-${EXTEN}-${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)}-${UNIQUEID},m)
exten => _0[1-2]XX,n,Dial(SIP/room01phone${EXTEN:0:2}, 30)

exten => _0[3-6]XX,1,Ringing
exten => _0[3-6]XX,n,AGI(/root/taranis.agi, ${EXTEN:2})
exten => _0[3-6]XX,n,Set(CALLERID(name)=${CALLERNAME})
exten => _0[3-6]XX,n,Set(MONITOR_EXEC=/root/rename_recording)
exten => _0[3-6]XX,n,Monitor(wav,${CALLERID(num)}-${EXTEN}-${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)}-${UNIQUEID},m)
exten => _0[3-6]XX,n,Dial(SIP/room02phone${EXTEN:0:2}, 30)

Alternative dialplan for automated fallback if phone01 is busy:



exten => _1XX,1,Ringing
exten => _1XX,n,AGI(/root/taranis.agi, ${EXTEN:2})
exten => _1XX,n,Set(CALLERID(name)=${CALLERNAME})
exten => _1XX,n,Set(CALLERID(num)=${CALLERID(num):1}${EXTEN:1})
exten => _1XX,n,Set(MONITOR_EXEC=/root/rename_recording)
exten => _1XX,n,Monitor(wav,${CALLERID(num)}-0${EXTEN}-${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)}-${UNIQUEID},m)
exten => _1XX,n,Dial(SIP/room01phone0${EXTEN:0:1}, 30)
exten => _1XX,n,NoOp( Dial Status: ${DIALSTATUS})
exten => _1XX,n,Goto(1XX-${DIALSTATUS},1)

exten => 1XX-CHANUNAVAIL,1,Dial(SIP/room01phone02, 30)

exten => _[3-6]XX,1,Ringing
exten => _[3-6]XX,n,AGI(/root/taranis.agi, ${EXTEN:2})
exten => _[3-6]XX,n,Set(CALLERID(name)=${CALLERNAME})
exten => _[3-6]XX,n,Set(CALLERID(num)=1${EXTEN:1})
exten => _[3-6]XX,n,Set(MONITOR_EXEC=/root/rename_recording)
exten => _[3-6]XX,n,Monitor(wav,${CALLERID(num)}-0${EXTEN}-${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)}-${UNIQUEID},m)
exten => _[3-6]XX,n,Dial(SIP/room02phone0${EXTEN:0:1}, 30)

rename_recording to rename the audio file once completed:

set -x
mv $path1 ${path1%/*}/conference-${path1##*/}
mv $path2 ${path2%/*}/conference-${path2##*/}


all: clean check

        rm -fR /tmp/1

      	mkdir -p /tmp/1/2/3/4
	touch /tmp/1/2/3/4/5.wav
	touch /tmp/1/2/3/4/6.wav
	/root/rename_recording /tmp/1/2/3/4/5.wav /tmp/1/2/3/4/6.wav
	[ -e /tmp/1/2/3/4/conference-5.wav ]
	[ -e /tmp/1/2/3/4/conference-6.wav ]

taranis.agi to retrieve callerid(name) corresponding to extensions suffixes from an xml file:

name=$(xmlstarlet sel -t -m "/roles/role[@id=$1]" -v @abbrev /var/www/taranis/roles.xml)

roles.xml to map extensions suffixes to callerid(name):

<?xml version="1.0"?>
<?xml-stylesheet href="roles.xsl" type="text/xsl" ?>
  <role id="01" abbrev="Asso. environnement" name="Association de protection de l'environnement"/>
  <role id="02" abbrev="CHR du Havre" name="CHR du Havre"/>
  <role id="03" abbrev="Grande surface" name="Directeur de grandes surfaces"/>
  <role id="04" abbrev="Coop pêcheurs" name="Directeur de la coopérative des pêcheurs de l'estuaire de la Seine"/>
  <role id="05" abbrev="LD Lines" name="Directeur LD Lines"/>
  <role id="06" abbrev="Eau et Assainissement" name="Direction Eau et Assainissement"/>
  <role id="07" abbrev="Ecole" name="Directrice Ecole Amiral Courbet"/>
  <role id="08" abbrev="Ville du Havre" name="Elu de la ville du Havre"/>
  <role id="09" abbrev="Gendarmerie 76" name="Gendarmerie 76"/>
  <role id="10" abbrev="France Info" name="Journaliste de France Info"/>
  <role id="11" abbrev="France 3" name="Journaliste France 3 Baie de Seine"/>

roles.xsl to pretty print an extensions sheet:

<?xml version="1.0" encoding="UTF-8"?>


<xsl:output method="xml" indent="yes" encoding="UTF-8"/>

<xsl:template match="/roles">
      <title>taranis roles</title>
    <link rel="stylesheet" type="text/css" href="roles.css" />
        <xsl:apply-templates select="role">

<xsl:template match="role">
    <td><xsl:value-of select="@id"/></td><td><xsl:value-of select="@name"/></td>


roles.css to style the extensions sheet:

td {
    border: solid black 1px;
    width: 100px;
    text-align: right;
    padding: 20px;
    padding: 20px;
    -moz-border-radius: 10px;

Created by: bkuhn, Last modification: Fri 05 of Nov, 2010 (23:29 UTC) by admin
Please update this page with new information, just login and click on the "Edit" or "Discussion" tab. Get a free login here: Register Thanks! - Find us on Google+