0. 写在前面 / Preface
- 下文的软件安装和介绍主要基于 debian 13 官方仓库中的内容,非 osmocom 提供的仓库。
- Debian 官方仓库打包的 osmo-* 包之间未指明依赖关系,可以理解成 debian 认为软件运行上无依赖关系,因此没有相互依赖,但是实际功能上是存在依赖关系的。
- Debian 打包的 DEB 包名、内容物均与 osmocom 的包有所区别,尤其是 osmo-trx 包缺失 osmo-trx-uhd 二进制。(可以考虑自行编译 osmo-trx,或者从 osmocom 仓库的对应包中提取出二进制 osmo-trx-uhd)
1. osmocom 框架功能介绍 / osmocom components
1 2 3 4 5 6 7 8 9 10 11 12 |
# osmo-trx: osmo-bts 和 SDR 之间的桥梁,负责 Layer1 通信, 代码来源于 OpenBTS 的 Transceiver52M (针对 UHD 的二进制就是 osmo-trx-uhd) # osmo-bts: GSM Base Transceiver Station , 基站主要组成部分,包含以下几个程序 # osmo-bts-trx: 配合 osmoTRX 以支持 SDR 设备 # osmo-bts-* : 用于其他商用基站设备 # osmo-bsc: Base Station Controller # osmo-msc: Mobile Switching Center, 2G/3G 电路交换的核心服务, 负责 Layer 3 层面的设备接入 # osmo-mgw: Media Gateway, 负责 2G/3G 电路交换网络中的语音功能 # osmo-hlr: Home Location Registrar, 管理 ME 订阅 # osmo-stp: SIGTRAN STP (Signaling Transfer Point), 不同组件之间通信的协议 # osmo-pcu: GPRS/EDGE Packet Control Unit # osmo-sgsn: Serving GPRS Support Node # osmo-ggsn: Gateway GPRS Support Node, GPRS 网关功能 |
-
以 osmoBTS 为中心的功能框图
-
以 osmoBSC 为中心的功能框图
-
以 osmoMSC 为中心的功能框图
-
以 osmoSGSN 为中心的功能框图
2. 环境准备 / Preparation
系统版本: Debian 13 (Trixie)
1 2 3 4 5 6 7 8 |
# uhd drivers apt install uhd-host libuhd4.3.0 --no-install-recommends # python3-uhd may recommends gnuradio and lots of packages # needed for GSM voice & sms apt install osmo-trx osmo-bts osmo-bsc osmo-msc osmo-mgw osmo-hlr osmo-stp # additional packages needed for GPRS/EDGE apt install osmo-ggsn osmo-sgsn osmo-pcu |
3. 软件配置 / Configuration
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# TRX, enable egprs sed -i 's/egprs disable/egprs enable/g' /etc/osmocom/osmo-trx-uhd.cfg # BSC, change MCC/MNC sed -i 's/country code *.*/country code 460/g' /etc/osmocom/osmo-bsc.cfg # BSC, enable GPRS and edit GGSN server address & port sed -i 's/gprs mode *.*/gprs mode egprsn gprs nsvc 0 remote ip 127.0.0.1n gprs nsvc 0 remote udp port 23000/g' /etc/osmocom/osmo-bsc.cfg # BSC, set time slots to dynamic mode, or manually allocate some time slots for GPRS to work sed -i 's/phys_chan_config TCH/F/phys_chan_config DYNAMIC/OSMOCOM/g' /etc/osmocom/osmo-bsc.cfg # SGSN, disable auth from SGSN to HLR sed -i 's/authentication required/authentication optional/g' /etc/osmocom/osmo-sgsn.cfg # HLR, auto subscribe for UE/ME echo ' subscriber-create-on-demand msisdn-from-imsi cs+ps' >> /etc/osmocom/osmo-hlr.cfg # NAT for GPRS # iptables -t nat -I POSTROUTING -j MASQUERADE does not work, will result in osmo-trx stop working iptables -t nat -I POSTROUTING -s 172.16.222.0/24 -j MASQUERADE |
4. 运行 / Launch
-
基础的语音和短信功能
1234567osmo-trx-uhd -C /etc/osmocom/osmo-trx-uhd.cfgosmo-bts-trx -c /etc/osmocom/osmo-bts-trx.cfgosmo-bsc -c /etc/osmocom/osmo-bsc.cfgosmo-msc -c /etc/osmocom/osmo-msc.cfgosmo-stp -c /etc/osmocom/osmo-stp.cfgosmo-hlr -c /etc/osmocom/osmo-hlr.cfgosmo-mgw -c /etc/osmocom/osmo-mgw.cfg -
GPRS 数据功能还需要运行以下程序
123osmo-pcu -c /etc/osmocom/osmo-pcu.cfgosmo-ggsn -c /etc/osmocom/osmo-ggsn.cfgosmo-sgsn -c /etc/osmocom/osmo-sgsn.cfg
5. 一些技巧 / Some tricks
- 发送短信
1234# 通过 telnet 连接到 MSC 的控制台发送短信telnet 127.0.0.1 4254enablesubscriber msisdn DST sms sender msisdn SRC send HelloWorld