April 30, 2008
filed late at night by DrScofield in: from the grid, hacking, linux
technorati tags:
QR code for this entry · average time to read 0:45 minutes

just thought i’d let you participate in today’s adventure: triggered by ansgar commenting on ubuntu offering him to upgrade to ubuntu 8.04 “hardy heron” i though, “hmm, good idea, let’s do a quick update”…

…well, a couple of hours later i seemed to be back in business, hardy heron was installed on “my” x60 and i was just about do another OpenSim build — when i noticed that nant was seg faulting! now, wait a moment, it clearly was not supposed to do that. ok, can happen, what with new libs and all that. so, let’s walk on over to /usr/local/src/mono/nant-0.86b and do a re-install. should be easy, peasy…

…except it wasn’t: mono’s compiler mcs kept seg faulting as well! hmmm.

ok. let’s reinstall mono. following my own script i started the re-install — which crashed as well after about 5min of mucking around.

panic stations!

googling around it transpired that this would happen when running hardy heron with a custom compiled kernel of pre-2.6.24 vintage — which i was :-(

i’m happy to report that with 2.6.25 mono is running again :-)

all content posted on these pages is an expression of my own mind. my employer is welcome to share these opinions but then again he might not want to.
April 29, 2008
filed in the early afternoon by DrScofield in: void
technorati tags:
QR code for this entry · average time to read 1:28 minutes

until a couple of days ago, opensim would only run in console mode: whenever you started OpenSim you would end up at a prompt inside OpenSim’s very own console — which is very convenient if you want to manage it that way. it is rather inconvenient if you want to start OpenSim as a daemon in the background (and control it via the RemoteAdminPlugin, for example).

as of OpenSim’s subversion release r4390 the basic support for running OpenSim without such a console is in the code base and all you need to do is invoke OpenSim with the -background True commandline parameter:

% mono --debug OpenSim.exe -background True

note: that’s just a single dash for -background True!

another patch is on its way that not only adds code to properly shutdown OpenSim when the admin_shutdown XmlRpc method is invoked but it also adds the shutdown.py script:1

you can either pass in the server URI and password to use via commandline parameters, or you can create .opensim-console.rc in your home directory and set default values:

[opensim]
server = http://127.0.0.1:9000/
password = secret

then all you need to do to shutdown your OpenSim server is: invoke shutdown.py


  1. to be found in share/python/console/shutdown.py

all content posted on these pages is an expression of my own mind. my employer is welcome to share these opinions but then again he might not want to.
April 22, 2008
filed around lunchtime by DrScofield in: from the grid
technorati tags:
QR code for this entry · average time to read 1:55 minutes

last week i described how to set up asterisk & opensim. a rather useful tool to test the whole setup is libsecondlife’s TestClient which (as of release 1758) contains commands to retrieve the voice account details and also to obtain the voice parcel info.

you start up your freshly compiled TestClient1

% mono --debug TestClient --first Foo --last Bar --pass secret
...
1 avatars online>

and then you issue the voiceaccount command to obtain the voice account credentials:2

1 avatars online> voiceaccount
DEBUG [libsecondlife]: New CAPS request to 
https://sim4042.agni.lindenlab.com:1204/cap/…. initiated
Voice Account for Ghostly Writer: 
    user “x2MOzi4T1Sq-qsfh77_Mnag==”, 
    password “XXXXXXXXXXXXXXX”
1 avatars online> DEBUG [Ghostly Writer]: Voice version 1 verified

…this tells us the voice account user name3 and password4. next you can issue the voiceparcel command to obtain the parce voice info details for the parcel you are currently on…

1 avatars online> voiceparcel
DEBUG [libsecondlife]: New CAPS request to 
https://sim4042.agni.lindenlab.com:12043/cap/… initiated
Parcel Voice Info request for Ghostly Writer: 
    region name “Zurela”, 
    parcel local id 26, 
    channel URI sip:confctl-243489@bhr.vivox.com

…which returns the region, parcel local ID, and the channel URI (the “conf call”) for that parcel.

repeating the whole exercise with OpenSim gives us this output:

% mono TestClient.exe --first Foo --last Bar --pass secret \
        --loginuri http://127.0.0.1:9000/
DEBUG [libsecondlife]: New CAPS request to http://127.0.0.1:9000/ initiated
DEBUG [Foo Bar]: Setting InventoryRoot to d8913a4b-…
DEBUG [Foo Bar]: Login status: ConnectingToSim: Connecting to simulator…
INFO [Foo Bar]: Connecting to (127.0.0.1:9000)
INFO [Foo Bar]: Received a region handshake for user error (127.0.0.1:9000)
DEBUG [libsecondlife]: New CAPS request to 
http://127.0.0.1:9000/CAPS/… initiated
DEBUG [Foo Bar]: Login status: Success: Welcome to OpenSim
Logged in Foo Bar
Type quit to exit.  Type help for a command list.
1 avatars online> DEBUG [Foo Bar]: Got capabilities: 
    UpdateNotecardAgentInventory 
    NewFileAgentInventory 
    FetchInventoryDescendents 
    MapLayer UpdateScriptTaskInventory 
    UpdateScriptAgentInventory ParcelVoiceInfoRequest 
    ProvisionVoiceAccountRequest
INFO [Foo Bar]: Connecting to (127.0.0.1:19999)
INFO [Foo Bar]: Received a region handshake for solid (127.0.0.1:19999)
1 avatars online>
1 avatars online> voiceaccount
DEBUG [libsecondlife]: New CAPS request to 
http://127.0.0.1:9000/CAPS/… initiated
Voice Account for Foo Bar: 
    user “xJ_Mn9bMsTkWxiduZkM4zSw==”, 
    password “$1$a857bc518438f33c16504831a5a47dd0″

and voiceparcel:

1 avatars online> voiceparcel
DEBUG [libsecondlife]: New CAPS request to 
http://127.0.0.1:9000/CAPS/… initiated
Parcel Voice Info request for Foo Bar: 
    region name “user error”, 
    parcel local id 1, 
    channel URI sip:54a9888b-…-85d45956bc1b@secondlife.zurich.ibm.com

a bit different, but in essence the same.


  1. it needs to be compiled from the libsecondlife subversion code base

  2. i’ve changed the formatting to fit the output within the blog space, so the real output is a bit differently formatted. 

  3. the UUID of your avatar, base-64 encoded…and, yes, i cheated. can you find out which avatar i logged in for this example? ;-) 

  4. X-ed out here. 

all content posted on these pages is an expression of my own mind. my employer is welcome to share these opinions but then again he might not want to.
April 18, 2008
filed around lunchtime by DrScofield in: from the grid
technorati tags:
QR code for this entry · average time to read 6:57 minutes

if you’ve been following the opensim-commits mailing lists recently, you will have noticed that among the flurry of bug fixes and new features were a couple of commits mentioning the magic terms voice support. based on the the voice technology entry on wiki.secondlife.com, and also jhurliman’s libsl VoiceManager and VoiceTest code we have been working on adding voice capabilities required to interact with Linden Lab’s SecondLife® client to OpenSim.

i’ll try and explain what we’ve achieved so far in the following sections. if you are impatient and want to skip the pretty pictures and high-level explanations you can use the following mini-table of contents:

asterisk-opensim integration

with the first iteration we refactored OpenSim’s capability system so that region module’s could contribute their capabilities to the seed capability and added a very simple, plain VoiceModule.

the second iteration (subversion r4236) now has a new voice module, AsteriskVoiceModule. also, in share/python/asterisk you should find a python XmlRpc server called asterisk-opensim.py. together with the open-source asterisk VoIP server both bring us quite a bit closer to our goal of voice support for OpenSim.

to understand how AsteriskVoiceModule and asterisk-opensim.py and your SecondLife client play together, let’s take a look at the following figure:

automatic SIP account creation

when the SecondLife client logs in to the Linden Lab grid or to an OpenSim grid, among the first things it does (once it got its seed capabilties from the grid) is to ask the grid server for the voice acount details (#1, ProvisionAccountRequest in the figure above). these voice account details basically are your avatar’s SIP account details which your SecondLife client is going to pass on to SLVoice(.exe).1 in our case, AsteriskVoiceModule deals with the incoming caps request from the SecondLife client: it

  • retrieves the avatar’s UUID and base64-encodes it, and
  • generates a one-time password (otp), and then
  • it then issues an account_update XmlRpc call to our asterisk-opensim.py XmlRpc server running on the same box as our asterisk server (#2, account_update).

asterisk-opensim.py checks that the XmlRpc call is correct and then updates the MySQL database that we use to configure asterisk in realtime by adding a dialplan for the UUID of our avatar (which basically creates a SIP account for our avatar)(#3, update extensions_table) — the MySQL database becomes effective (#4) the next time asterisk queries the database for its dialplan.

once asterisk-opensim.py has done its job, it tells AsteriskVoiceModule that it was successful (#5). AsteriskVoiceModule then returns the newly created (or updated) voice account information to your SecondLife client (#6).

Your SecondLife client then passes that information on to SLVoice which has nothing better to do than go and register with our asterisk server…

…well, it would, except, SLVoice as packaged with the normal SecondLife client does not know about our asterisk server. we’ll need to supply a replacement SLVoice client before we can claim success!2 you might want to check out the voipforvw project for one example of such a replacement.

ok, so, we now have a SIP account, and our potential SLVoice replacement has registered with the asterisk server (well, once we’ve got it, that is ;-)) — how do we actually get voice and get to talk to other avatars? that’s what the next section is all about…

automatic conference call setup

lacking a proper spatial sound module for asterisk, we are just going to assign a conference call number to each and every region in our grid. sure, the idea being that whenever you avatar enters a new region, your SecondLife client will dial into the conference call for that region and leave the conference call of the old region.

how does your SecondLife client get the conference call number then? well, it turns out that the SecondLife client issues a ParcelVoiceInfo request to the grid each time it enters a new region3. again, the figure below illustrates what happens.

our AsteriskVoiceModule will receive the ParcelVoiceInfo call (#1) and will in turn issue a region_update XmlRpc call to asterisk-opensim (#2) containing the region’s UUID4.

asterisk-opensim verifies the XmlRpc call from AsteriskVoiceModule and will then add records to asterisk’s MySQL database (#3) to

  • create (or update) a conference call with the region UUID as the dial-in “number”
  • create appropriate dial plan entries for that conference call

asterisk will pick up the changes the next time it goes through its dial plan (#4)

and, once done, asterisk-opensim returns success: true to AsteriskVoiceModule (#5), which then returns the region voice details to your SecondLife client (#6):

  • region_name — the name of the region your avatar is currently in
  • parcel_id — i assume this contains the local ID of the piece of land your avatar is on
  • channel_uri — basically, the UUID of the region plus the value of the conf_domain parameter from the [AsteriskVoiceModule] section from OpenSim.ini

your SecondLife client passes the received information on to the SLVoice application which will then dial into to the conference call (#7) for the new region (and leave the old conf call for the old region).5

setting it all up

to make this all work we need to

  • enable AsteriskVoiceModule
  • configure asterisk-opensim.py
  • setup asterisk’s MySQL database
  • configure asterisk to query the MySQL database for its dial plan

the following sections explain each step in more detail.

setting it all up: AsteriskVoiceModule

to enable the AsteriskVoiceModule you need to add the following lines to OpenSim.ini

[AsteriskVoice]
enabled = true
; SIP account server domain
sip_domain = testserver.com
; SIP conf server domain
conf_domain = testserver.com
; URL of the asterisk opensim frontend
asterisk_frontend = http://testserver.com:49153/
; password for the asterisk frontend XmlRpc calls
asterisk_password = bah-humbug
; timeout for XmlRpc calls to asterisk front end (in ms)
asterisk_timeout = 3000
; salt for asterisk nonces
asterisk_salt = some_secret_here

what do the individual parameter mean:

enabled
if true enable the module. make sure you have the plain vanilla Voice module disabled
sip_domain
the SIP domain to append to UUIDs for user accounts (can be empty)
conf_domain
the SIP domain to append to UUIDs for region conference call IDs
asterisk_frontend
the URL of the asterisk-opensim.py front end
asterisk_password
the password required for the asterisk-opensim.py XmlRpc calls
asterisk_timeout
AsteriskVoiceModule will wait this long for XmlRpc calls to asterisk-opensim.py to succeed (in ms)
asterisk_salt
salt to use for generating random one-time password for user SIP accounts

setting it all up: asterisk-opensim.py

asterisk-opensim.py is configured through it’s own config file. you supply the path to the config file via the --config option (just invoke asterisk-opensim.py with --help to get usage instructions). the config file looks like this:

[xmlrpc]
baseurl = http://127.0.0.1:53263/
debug   = true

[mysql]
server   = localhost
database = asterisk
user     = asterisk
password = asterisk
debug    = true

[mysql-templates]
tables = /path/to/create-table.sql
user   = /path/to/create-user.sql
region = /path/to/create-region.sql
debug    = true

we have three sections:

[xmlrpc]
here you configure the base URL for the account_update and region_update XmlRpc calls (currently you cannot supply a path name, we only take hostname and port)
[mysql]
here you configure which server to use, the name of the asterisk database, the user name and password of the MySQL user and whether you want debugging output or not.
[mysql-templates]
these are the path names to the templates that we use to create the required MySQL tables and also to update user account and update region conference calls. also, you can switch on debugging here.

setting it all up: MySQL database

setting up MySQL is pretty easy: you only need to create the asterisk database and the asterisk user:

# mysql -u root -p
mysql> create database asterisk;
Query OK, 1 row affected (0.02 sec)

mysql> use asterisk;
Database changed
mysql> grant all on asterisk.* to 'asterisk'@'localhost' identified by 'asterisk';
Query OK, 0 rows affected (0.09 sec)

mysql> quit;
Bye

that’s it. asterisk-opensim.py will take care of creating the necessary tables for you.

you might want to change the user name (the 'asterisk part of 'asterisk'@'localhost') and password (again, the 'asterisk' part in identified by 'asterisk') — but make sure you adapt your [asterisk-opensim.cfg](#setup-asterisk-opensim) and your asterisk configuration accordingly.

setting it all up: asterisk

we need to configure asterisk to use the ODBC database interconnect (also called asterisk realtime).

in your asterisk configuration directory — on ubuntu that’s /etc/asterisk — you need to make sure that you have

sipusers => odbc,asterisk,ast_sipfriends
sippeers => odbc,asterisk,ast_sipfriends
extensions => odbc,asterisk,extensions_table

in extconfig.conf

then in res_odbc.conf you need to have the following section:

[asterisk]
enabled => yes
dsn => asterisk-connector
username => asterisk
password => asterisk
;pooling => no
;limit => 5
pre-connect => yes

this assumes that your asterisk database is “asterisk”. likewise, that the MySQL username and password is ‘asterisk’ — if you used different values in your MySQL setup , you, of course, need to reflect that here.

then, you need to have the following extensions.conf:

[general]
static=yes
writeprotect=no
clearglobalvars=no

[globals]
CONSOLE=Console/dsp


[avatare]
switch => Realtime/@

finally, you need to have an empty sip.conf:

# mv sip.conf sip.conf.backup
# touch sip.conf

that’s about it, really.


  1. on windows it’s SLVoice.exe, on linux it’s just SLVoice

  2. emphasizing this so as not to get lots of emails telling me that your voice setup does not work. no, kids, we are not there yet. but we can see the city lights approaching… 

  3. it might actually do so, everytime you move into a new parcel (or land in OpenSim terminology), i haven’t checked that yet… “left as an exercise to the reader” ;-) 

  4. actually the region UUID plus the conf_domain parameter from the [AsteriskVoiceModule] config section in OpenSim.ini

  5. again, this requires a replacement SLVoice application, the standard one won’t do this. 

all content posted on these pages is an expression of my own mind. my employer is welcome to share these opinions but then again he might not want to.