配置 Asterisk 同 OpenBTS 工作

理论上 OpenBTS 同 Asterisk 集成在一起是很简单的:把每个 SIM 在 Asterisk 中配置成一个 SIP 用户, 用 IMSI 作为 SIP 的用户名。

因此以下两个步骤便可以为 OpenBTS 提供订户:

  1. 从 SIM 中获得 IMSI。
  2. sip.conf 和 extensions.conf 为此新的 SIP 用户配置相应的支持字条。

获取 IMSIs

有好几种方法为一个 SIM 获取 IMSI, 因此它可以被编程(糅合)到 Asterisk 的配置文件中。 使用哪种方法取决于 SIMs 的容量,你需提供。

由 OpenBTS 自身获得 IMSI

对于很小数量的 SIMs,这是一种最简单的方法。
无论何时手持试图注册到 OpenBTS, 它将发送手持一个辨识码。 可以强迫手持使用 IMSI 作为辨识码。 当手持试图注册时,便可以从 OpenBTS 的终端画面捕获 IMSI。 下面是操作步骤:
    • 使用正确的 GSM 频段。 确实手持被配置使用和 OpenBTS 代码应用相同的频段,(对此)没有二话。
    • 重置手持的 TMSI。 其步骤是来自 GSM 04.08。 关闭手持。 去掉电源和 SIM。 重新安装并打开手持的电源。 这将清除储存在手持中的任何 TMSI
    • 让手持试图注册。
  • 对于版本 "Jean Lafitte" 和其之前的: Start running the full OpenBTS (OpenBTS + transceiver + Asterisk). Pipe out output of the OpenBTS binary through "| grep Control" and watch for something like this:
FACCHDispatch.cpp:53 ControlLayer FACCHDispatcher waiting for ESTABLISH RadioResource.cpp:87 ControlLayer AccessGrantResponder RA=27 when=0:7734
RadioResource.cpp:127 ControlLayer AccessGrantResponder sending PageMode=(0) DedicatedModeOrTBF=(TMA=0 Downlink=0 DMOrTBF=0) ChannelDescription=(typeAndOffset=SDCCH/4-3 TN=0 TSC=0 ARFCN=29) RequestReference=(RA=27 T1'=5 T2=12 T3=33) TimingAdvance=0
SDCCHDispatch.cpp:101 ControlLayer SDCCHDispatcher got MM Location Updating Request MobileIdentity=(IMSI=310410186585294)
MobilityManagement.cpp:111 ControlLayer LocationUpdatingController MM Location Updating Request MobileIdentity=(IMSI=310410186585294)
MobilityManagement.cpp:121 ControlLayer LocationUpdatingController waiting for registration
MobilityManagement.cpp:137 ControlLayer LocationUpdatingController : SIPRegistration -> FAIL
SDCCHDispatch.cpp:136 ControlLayer SDCCHDisptacher waiting for RELEASE
SDCCHDispatch.cpp:97 ControlLayer SDCCHDisptacher waiting for ESTABLISH
  • 对于 "Jean Lafitte" 和其之后的: Start OpenBTS and Asterisk with the OpenBTS logging level set to "INFO" and watch for something like this in the log:
RadioResource.cpp:152: AccessGrantResponder RA=0x15 when=0:1192710 age=25 TOA=0.0000
RadioResource.cpp:196: AccessGrantResponder sending PageMode=(0) DedicatedModeOrTBF=(TMA=0 Downlink=0 DMOrTBF=0) ChannelDescription=(typeAndOffset=SDCCH/4-0 TN=0 TSC=0 ARFCN=975) RequestReference=(RA=21 T1'=3 T2=12 T3=24) TimingAdvance=0
MobilityManagement.cpp:119: LocationUpdatingController MM Location Updating Request LAI=(MCC=901 MNC=55 LAC=0x29b) MobileIdentity=(TMSI=0x49ffcddd)
MobilityManagement.cpp:172: LocationUpdatingController registration FAIL: IMSI=234100223456161
  • In either version, the SIP registration attempt will return "FAIL" because this IMSI is not yet provisioned in Asterisk.
  • If you're really clever, you'll write some kind of Python script to catch the log output and automatically update the Asterisk configuration files. If you do that, please share your scripts with the rest of us. That would make this technique applicable to very large numbers of SIMs in situations where acceptance rules can be applied based on the upper digits of the IMSI.

Use the GSM "AT" Interface

Many GSM devices support a Hayes-style "AT" command interface, defined in GSM 07.07. This interface supports the "AT+CIMI" command, described in GSM 07.07 Section 5.6, which will return the IMSI of the device's installed SIM.

This is a good approach if you have a device that affords easy SIM changes, like a "MultiTech GSM modem":http://www.multitech.com/PRODUCTS/Families/MultiModemGPRS/ and need to provision a few dozen subscribers.Again, if you're really clever you'll write a script to automate that. And if you're a good person you'll share it with the rest of us.

Order Lots of SIMs

If you need even larger numbers of SIMs provisioned you might consider ordering a batch of them with sequential IMSIs that can be easily programmed into Asterisk with a script.

Programming IMSIs Into Asterisk

To provision an IMSI into Asterisk you will need to modify two files: sip.conf and extensions.conf. These files are normally located in /etc/asterisk.

Creating a SIP User in sip.conf

The minimal entry for the IMSI in sip.conf looks like this:
<pre>
 r310410186585294
 canreinvite=no
 type=friend
 allow=gsm
 context=sip-external
 host=dynamic
</pre>
This defines a SIP user called "310410186585294".

Assigning an Address in extensions.conf

We recommend this macro for dialing OpenBTS users:

<pre>
 [macro-dialGSM]
 exten => s,1,Dial(SIP/${ARG1})
 exten => s,2,Goto(s-${DIALSTATUS},1)
 exten => s-CANCEL,1,Hangup
 exten => s-NOANSWER,1,Hangup
 exten => s-BUSY,1,Busy(30)
 exten => s-CONGESTION,1,Congestion(30)
 exten => s-CHANUNAVAIL,1,playback(ss-noservice)
 exten => s-CANCEL,1,Hangup
</pre>
(And if any Asterisk expert has improvements to that, please feel free to submit them.)

With that macro in place, the GSM handset can be assigned an extension just like any other Asterisk terminal device.
For example, this macro assigns extension "2103" to the handset with ISMI "310410186585291":
<pre>
 ;; the name in the brackets is the context, it should be the same with the context line in sip.conf
 [sip-external]
 exten => 2103,1,Macro(dialGSM,310410186585291)
</pre>

And this macro allows a specific block of 1,000 AT&T SIMs (310410186585000-310410186585999) to be dialed by the last 4 digits of the IMSI:

<pre>
 exten => _5XXX,1,Macro(dialGSM,310410186585${EXTEN:-3})
</pre>





注:Setting Up Asterisk to Work with OpenBTS(原文出处,翻译整理仅供参考!)