Howto OpenBSC with Asterisk and LCR
This is a short walk-through to setup OpenBSC and LCR with Asterisk.
In the end we'll have a working setup to route calls from our BTS to the PTSN via VoIP.
Prerequisites
- OpenBSC equipment (BTS, E1 Card)
- We're using a Siemens BS11 microBTS and a Cologne Chips E1 PCI card
- The latest snapshot from the LibOmsocore repository
- git clone git://git.osmocom.org/libosmocore.git
- The latest snapshot from the OpenBSC repository
- git clone git://git.osmocom.org/openbsc.git
- LCR from git repository
- git-clone git://git.misdn.org/lcr.git/
- A working kernel for your Linux system
- Support for your E1 card
- mISDN's l1loop module (mISDN_l1loop.ko)
- mISDN's DSP module (mISDN_dsp.ko)
- You can obtain a working package for Debian at https://brezn.muc.ccc.de/~codec/openbsc/
- Supports cards from Cologne Chips and Junghanns
- libgsm + header files (libgsm / libgsm-dev on Debian)
- A working Asterisk setup
- Original howto from https://brezn.muc.ccc.de/~codec/openbsc/howto.txt
Alternatively you can download a snapshot of the source codes, which have been tested: http://www.linux-call-router.de/download/ (go to the latest lcr-* subdirectory)
Installation
First of all we assume the following:
- Layout of your working directory:
- libosmocore/ - checkout from LibOmsocore rep
- openbsc/ - checkout from OpenBSC repo
- lcr/ - checkout from LCR repo
- Installation directories:
- /opt/openbsc for OpenBSC
- /opt/lcr for LCR
We need to compile and install LibOsmocore and OpenBSC first:
$ cd libosmocore/ $ autoreconf -i $ ./configure $ make $ sudo make install $ cd ../openbsc/openbsc/ $ autoreconf --install --force $ ./configure --prefix=/opt/openbsc $ make $ sudo make install
After that we're going for LCR:
$ cd ../../lcr
First of all, we have to link the source directory of OpenBSC and LibOsmocore in the lcr-Directory:
$ ln -s ../libosmocore/ . $ ln -s ../openbsc/openbsc/ .
Now we can go on with compiling LCR. Unfortunately, due to changes in OpenBSC, we have to install a patch for LCR, until the programmer of LCR will include this patch in the current version. The patch is attached to this document.
$ sh autogen.sh $ git-apply --verbose lcrOpenBSC.patch $ ./configure --prefix=/opt/lcr --with-asterisk --with-gsm-bs $ make $ sudo make install
and now we can copy the module into the modules' directory of Asterisk:
$ sudo cp chan_lcr.so /usr/lib/asterisk/modules/
LCR configuration
1. gsm in options.conf
The gsm option in /usr/local/lcr/options.conf needs to be activated. This can be
simply done by adding 'gsm' as a single line to the file.
Because it is a good idea to start Asterisk without root's privileges, we want to add these lines, too:
socketuser asterisk socketgroup asterisk
2. GSM interface in interface.conf
/usr/local/lcr/interface.conf holds an example for a GSM interface. Remove the comments
and use the example as is.
3. gsm.conf
Enable the debugging option in /usr/local/lcr/gsm.conf. We also need 2 mISDN loopback interfaces.
Create them with
$ sudo modprobe mISDN_l1loop pri=1 nchannel=30
You can check for the interfaces names with the misdn_info tool. All the default settings should work in a BS11 setup. You have just to give a value for 'config' and 'hlr', with the full path of your OpenBSC configuration file and HLR-DataBase.
4. Routing
We route all our calls to to asterisk at the moment, as we only have outgoing connectivity via IAX/SIP in our setup.
[main] interface=GSM : remote application=asterisk context=btsctrl
Calls will go to the context btsctrl in Asterisk.
Asterisk configuration
Our setup connects to an external Asterisk via SIP - as we don't have a second ISDN interface.
chan_lcr for Asterisk comes with LCR (compiled with --with-asterisk). You only need to load the channel driver and maybe check the permissions of the LCR socket (/var/tmp/lcr.socket) - Asterisk on Debian uses a Set UID wrapper.
To load chan_lcr automagically on startup add the following to your modules.conf:
load => chan_lcr.so
We've created an exclusive context in extensions.conf for OpenBSC/LCR:
[btsctrl]
exten => _02X.,1,GotoIf($[${CALLERID(name)} != ""]?4)
exten => _02X.,2,Set(CALLIDORIG=${CALLERID(num)})
exten => _02X.,3,Set(CALLERID(num)=02${CALLIDORIG})
exten => _02X.,4,Dial(LCR/GSM/${EXTEN:2},120)
Running OpenBSC/LCR and Asterisk
Now we're ready to start with our GSM network. Boot up the BS11 and start LCR with
$ sudo /opt/lcr/sbin/lcr start
You can also use 'fork' instead of 'start' to run LCR in daemon mode, but I'd rather go with fork AFTER you made you first successful call. (;
Now start Asterisk. It should connect to LCR right after startup. You can check this by running
$ sudo /opt/lcr/bin/lcradmin state
The UI should show
Remote: asterisk
in the upper left part.
Connect your phone and make your call(s).
Troubleshooting
Phones unable to connect
On the first run I had some problems with connecting my phones as the registration just timed out. I fixed this by starting over with a fresh HLR.
The call routing fails (somewhere)
Most problems occured within Asterisk for me as neither IAX2 or SIP was working. This was just some kind of problem within the configuration.
I can provide a working dialplan and SIP configuration if you need it.
Can't see the network
This was either related to the phone (a restart fixed it) or the BS11. After the first start I sometimes had to hardreset (as in reboot) the BS11.
Attachments
-
lcrOpenBSC.patch
(0.6 KB) - added by luca
3 years ago.
Patch for LCR to work with OpenBSC

