OsmoNITB LCR » History » Revision 14
Revision 13 (laforge, 02/19/2016 10:47 PM) → Revision 14/23 (laforge, 02/19/2016 10:48 PM)
h2. == Howto [[OpenBSC]] OpenBSC with Asterisk and LCR == This is a short walk-through to setup [[OpenBSC]] 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]]. h3. VoIP. === Prerequisites === * [[OpenBSC]] 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 !LibOmsocore repository *** * git clone git://git.osmocom.org/libosmocore.git * The latest snapshot from the [[OpenBSC]] 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) h3. === Installation === First of all we assume the following: * Layout of your working directory: *** * libosmocore/ - checkout from LibOmsocore !LibOmsocore rep *** * openbsc/ - checkout from [[OpenBSC]] OpenBSC repo *** * lcr/ - checkout from LCR repo * Installation directories: *** * /opt/openbsc for [[OpenBSC]] *** OpenBSC * /opt/lcr for LCR We need to compile and install LibOsmocore !LibOsmocore and [[OpenBSC]] OpenBSC first: <pre> {{{ $ cd libosmocore/ $ autoreconf -i $ ./configure $ make $ sudo make install $ cd ../openbsc/openbsc/ $ autoreconf --install --force $ ./configure --prefix=/opt/openbsc $ make $ sudo make install </pre> }}} After that we're going for LCR: <pre> {{{ $ cd ../../lcr </pre> }}} First of all, we have to link the source directory of [[OpenBSC]] OpenBSC and LibOsmocore !LibOsmocore in the lcr-Directory: <pre> {{{ $ ln -s ../libosmocore/ . $ ln -s ../openbsc/openbsc/ . </pre> }}} Now we can go on with compiling LCR. Unfortunately, due to changes in [[OpenBSC]], 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. <pre> {{{ $ sh autogen.sh $ git-apply --verbose lcrOpenBSC.patch $ ./configure --prefix=/opt/lcr --with-asterisk --with-gsm-bs $ make $ sudo make install </pre> }}} and now we can copy the module into the modules' directory of Asterisk: <pre> {{{ $ sudo cp chan_lcr.so /usr/lib/asterisk/modules/ </pre> h3. }}} === LCR configuration *1. === '''1. gsm in options.conf* options.conf'''[[BR]] 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. file.[[BR]] Because it is a good idea to start Asterisk without root's privileges, we want to add these lines, too: <pre> {{{ socketuser asterisk socketgroup asterisk </pre> *2. }}} '''2. GSM interface in interface.conf* interface.conf'''[[BR]] /usr/local/lcr/interface.conf holds an example for a GSM interface. Remove the comments and use the example as is. *3. gsm.conf* '''3. gsm.conf'''[[BR]] Enable the debugging option in /usr/local/lcr/gsm.conf. We also need 2 mISDN loopback interfaces. Create them with <pre> {{{ $ sudo modprobe mISDN_l1loop pri=1 nchannel=30 </pre> }}} 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]] OpenBSC configuration file and HLR-!DataBase. *4. Routing* '''4. Routing'''[[BR]] We route all our calls to to asterisk at the moment, as we only have outgoing connectivity via IAX/SIP in our setup. <pre> {{{ [main] interface=GSM : remote application=asterisk context=btsctrl </pre> }}} Calls will go to the context btsctrl in Asterisk. h3. === 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: <pre> {{{ load => chan_lcr.so </pre> }}} We've created an exclusive context in extensions.conf for [[OpenBSC]]/LCR: OpenBSC/LCR: <pre> {{{ [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) </pre> h3. }}} === Running [[OpenBSC]]/LCR OpenBSC/LCR and Asterisk === Now we're ready to start with our GSM network. Boot up the BS11 and start LCR with <pre> {{{ $ sudo /opt/lcr/sbin/lcr start </pre> }}} 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 <pre> {{{ $ sudo /opt/lcr/bin/lcradmin state </pre> }}} The UI should show <pre> {{{ Remote: asterisk </pre> }}} in the upper left part. Connect your phone and make your call(s). h3. === 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. h4. ==== 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. h4. ==== 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.