From fb00ae8a36f7f1f58f32878f9247bd061df935de Mon Sep 17 00:00:00 2001 From: FlUxIuS Date: Wed, 3 Jul 2024 17:10:47 +0200 Subject: [PATCH] Adding osmo* stack for 2G (radio+core) & 3G (core) --- Dockerfile | 1 + Dockerfiles/telecom.docker | 2 + config/osmobts/nitb/osmo-bsc.cfg | 53 ++++++++++++++++++++ config/osmobts/nitb/osmo-ggsn.cfg | 24 +++++++++ config/osmobts/nitb/osmo-hlr.cfg | 12 +++++ config/osmobts/nitb/osmo-hnbgw.cfg | 17 +++++++ config/osmobts/nitb/osmo-mgw-for-bsc.cfg | 16 ++++++ config/osmobts/nitb/osmo-mgw-for-hnbgw.cfg | 14 ++++++ config/osmobts/nitb/osmo-mgw-for-msc.cfg | 13 +++++ config/osmobts/nitb/osmo-msc.cfg | 16 ++++++ config/osmobts/nitb/osmo-sgsn.cfg | 19 +++++++ config/osmobts/nitb/osmo-stp.cfg | 13 +++++ config/osmobts/nitb/osmo-upf.cfg | 15 ++++++ config/osmobts/nitb/vty | 58 ++++++++++++++++++++++ config/osmobts/nitb/vty_sticky | 5 ++ scripts/telecom_software.sh | 48 +++++++++++++++++- 16 files changed, 325 insertions(+), 1 deletion(-) create mode 100644 config/osmobts/nitb/osmo-bsc.cfg create mode 100644 config/osmobts/nitb/osmo-ggsn.cfg create mode 100644 config/osmobts/nitb/osmo-hlr.cfg create mode 100644 config/osmobts/nitb/osmo-hnbgw.cfg create mode 100644 config/osmobts/nitb/osmo-mgw-for-bsc.cfg create mode 100644 config/osmobts/nitb/osmo-mgw-for-hnbgw.cfg create mode 100644 config/osmobts/nitb/osmo-mgw-for-msc.cfg create mode 100644 config/osmobts/nitb/osmo-msc.cfg create mode 100644 config/osmobts/nitb/osmo-sgsn.cfg create mode 100644 config/osmobts/nitb/osmo-stp.cfg create mode 100644 config/osmobts/nitb/osmo-upf.cfg create mode 100755 config/osmobts/nitb/vty create mode 100755 config/osmobts/nitb/vty_sticky diff --git a/Dockerfile b/Dockerfile index 182590b..451cd2d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -244,6 +244,7 @@ RUN ./entrypoint.sh srsran4G_5GNSA_soft_install RUN ./entrypoint.sh srsran5GSA_soft_install RUN ./entrypoint.sh Open5GS_soft_install RUN ./entrypoint.sh pycrate_soft_install +RUN ./entrypoint.sh osmobts_suite_soft_install RUN mkdir -p /sdrtools/ COPY run /sdrtools/run diff --git a/Dockerfiles/telecom.docker b/Dockerfiles/telecom.docker index ac57ad6..85d4ba1 100644 --- a/Dockerfiles/telecom.docker +++ b/Dockerfiles/telecom.docker @@ -15,6 +15,7 @@ RUN apt-fast update COPY scripts /root/scripts/ COPY rules /root/rules/ +COPY config /root/config WORKDIR /root/scripts/ RUN chmod +x entrypoint.sh @@ -27,6 +28,7 @@ RUN ./entrypoint.sh srsran4G_5GNSA_soft_install RUN ./entrypoint.sh srsran5GSA_soft_install RUN ./entrypoint.sh Open5GS_soft_install RUN ./entrypoint.sh pycrate_soft_install +RUN ./entrypoint.sh osmobts_suite_soft_install # More to come! RUN mkdir -p /sdrtools/ diff --git a/config/osmobts/nitb/osmo-bsc.cfg b/config/osmobts/nitb/osmo-bsc.cfg new file mode 100644 index 0000000..d2424a3 --- /dev/null +++ b/config/osmobts/nitb/osmo-bsc.cfg @@ -0,0 +1,53 @@ +network + network country code 901 + mobile network code 70 + bts 0 + type sysmobts + band GSM-1800 + location_area_code 23 + # This is the unit id that has to match the BTS configuration + ip.access unit_id 1800 0 + codec-support fr hr amr + gprs mode gprs + gprs nsvc 0 remote ip 192.168.0.9 + gprs nsvc 0 remote udp port 23000 + gprs nsvc 0 local udp port 23000 + gprs nsvc 0 nsvci 1800 + gprs nsei 1800 + gprs cell bvci 1800 + trx 0 + rf_locked 0 + arfcn 868 + nominal power 23 + timeslot 0 + phys_chan_config CCCH+SDCCH4 + timeslot 1 + phys_chan_config SDCCH8 + timeslot 2 + phys_chan_config TCH/F_TCH/H_PDCH + timeslot 3 + phys_chan_config TCH/F_TCH/H_PDCH + timeslot 4 + phys_chan_config TCH/F_TCH/H_PDCH + timeslot 5 + phys_chan_config TCH/F_TCH/H_PDCH + timeslot 6 + phys_chan_config TCH/F_TCH/H_PDCH + timeslot 7 + phys_chan_config PDCH +e1_input + e1_line 0 driver ipa +msc 0 + mgw remote-ip 192.168.0.9 + mgw remote-port 12427 + allow-emergency deny + codec-list hr3 + +log stderr + logging filter all 1 + logging print extended-timestamp 1 + logging print category 1 + logging print category-hex 0 + logging print level 1 + logging print file basename last + logging level set-all info diff --git a/config/osmobts/nitb/osmo-ggsn.cfg b/config/osmobts/nitb/osmo-ggsn.cfg new file mode 100644 index 0000000..9e7fccc --- /dev/null +++ b/config/osmobts/nitb/osmo-ggsn.cfg @@ -0,0 +1,24 @@ +log stderr + logging level all debug + logging filter all 1 + logging print category 1 +ggsn ggsn0 + gtp bind-ip 192.168.0.42 + apn internet + tun-device apn0 + type-support v4 + ip dns 0 192.168.0.1 + ip dns 1 9.9.9.9 + ip prefix dynamic 192.168.42.0/24 + no shutdown + default-apn internet + no shutdown ggsn + +log stderr + logging filter all 1 + logging print extended-timestamp 1 + logging print category 1 + logging print category-hex 0 + logging print level 1 + logging print file basename last + logging level set-all info diff --git a/config/osmobts/nitb/osmo-hlr.cfg b/config/osmobts/nitb/osmo-hlr.cfg new file mode 100644 index 0000000..09af47b --- /dev/null +++ b/config/osmobts/nitb/osmo-hlr.cfg @@ -0,0 +1,12 @@ +hlr + ussd route prefix *#100# internal own-msisdn + ussd route prefix *#101# internal own-imsi + +log stderr + logging filter all 1 + logging print extended-timestamp 1 + logging print category 1 + logging print category-hex 0 + logging print level 1 + logging print file basename last + logging level set-all debug diff --git a/config/osmobts/nitb/osmo-hnbgw.cfg b/config/osmobts/nitb/osmo-hnbgw.cfg new file mode 100644 index 0000000..99dcd24 --- /dev/null +++ b/config/osmobts/nitb/osmo-hnbgw.cfg @@ -0,0 +1,17 @@ +hnbgw + iuh + local-ip 192.168.0.9 + mgcp + mgw remote-ip 192.168.0.9 + mgw remote-port 22427 + pfcp + remote-addr 192.168.0.9 + +log stderr + logging filter all 1 + logging print extended-timestamp 1 + logging print category 1 + logging print category-hex 0 + logging print level 1 + logging print file basename last + logging level set-all info diff --git a/config/osmobts/nitb/osmo-mgw-for-bsc.cfg b/config/osmobts/nitb/osmo-mgw-for-bsc.cfg new file mode 100644 index 0000000..4b71ee2 --- /dev/null +++ b/config/osmobts/nitb/osmo-mgw-for-bsc.cfg @@ -0,0 +1,16 @@ +mgcp + bind ip 192.168.0.9 + # default port is 2427 (is used for MSC's MGW) + bind port 12427 +line vty + # default VTY interface is on 127.0.0.1 (used for MSC's MGW) + bind 127.0.0.2 + +log stderr + logging filter all 1 + logging print extended-timestamp 1 + logging print category 1 + logging print category-hex 0 + logging print level 1 + logging print file basename last + logging level set-all info diff --git a/config/osmobts/nitb/osmo-mgw-for-hnbgw.cfg b/config/osmobts/nitb/osmo-mgw-for-hnbgw.cfg new file mode 100644 index 0000000..060f1c0 --- /dev/null +++ b/config/osmobts/nitb/osmo-mgw-for-hnbgw.cfg @@ -0,0 +1,14 @@ +mgcp + bind ip 192.168.0.9 + bind port 22427 +line vty + bind 127.0.0.3 + +log stderr + logging filter all 1 + logging print extended-timestamp 1 + logging print category 1 + logging print category-hex 0 + logging print level 1 + logging print file basename last + logging level set-all info diff --git a/config/osmobts/nitb/osmo-mgw-for-msc.cfg b/config/osmobts/nitb/osmo-mgw-for-msc.cfg new file mode 100644 index 0000000..9b67cd4 --- /dev/null +++ b/config/osmobts/nitb/osmo-mgw-for-msc.cfg @@ -0,0 +1,13 @@ +mgcp + bind ip 192.168.0.9 +line vty + bind 127.0.0.1 + +log stderr + logging filter all 1 + logging print extended-timestamp 1 + logging print category 1 + logging print category-hex 0 + logging print level 1 + logging print file basename last + logging level set-all info diff --git a/config/osmobts/nitb/osmo-msc.cfg b/config/osmobts/nitb/osmo-msc.cfg new file mode 100644 index 0000000..1370f3b --- /dev/null +++ b/config/osmobts/nitb/osmo-msc.cfg @@ -0,0 +1,16 @@ +network + network country code 901 + mobile network code 70 +msc + mgw remote-ip 192.168.0.9 + # For nano3G: + iu rab-assign-addr-enc x213 + +log stderr + logging filter all 1 + logging print extended-timestamp 1 + logging print category 1 + logging print category-hex 0 + logging print level 1 + logging print file basename last + logging level set-all info diff --git a/config/osmobts/nitb/osmo-sgsn.cfg b/config/osmobts/nitb/osmo-sgsn.cfg new file mode 100644 index 0000000..84d32f7 --- /dev/null +++ b/config/osmobts/nitb/osmo-sgsn.cfg @@ -0,0 +1,19 @@ +sgsn + gtp local-ip 192.168.0.9 + ggsn 0 remote-ip 192.168.0.42 + ggsn 0 gtp-version 1 + auth-policy remote + gsup remote-ip 127.0.0.1 +ns + bind udp some + listen 192.168.1.20 23000 + accept-ipaccess + +log stderr + logging filter all 1 + logging print extended-timestamp 1 + logging print category 1 + logging print category-hex 0 + logging print level 1 + logging print file basename last + logging level set-all info diff --git a/config/osmobts/nitb/osmo-stp.cfg b/config/osmobts/nitb/osmo-stp.cfg new file mode 100644 index 0000000..40aed82 --- /dev/null +++ b/config/osmobts/nitb/osmo-stp.cfg @@ -0,0 +1,13 @@ +cs7 instance 0 + xua rkm routing-key-allocation dynamic-permitted + listen m3ua 2905 + accept-asp-connections dynamic-permitted + +log stderr + logging filter all 1 + logging print extended-timestamp 1 + logging print category 1 + logging print category-hex 0 + logging print level 1 + logging print file basename last + logging level set-all info diff --git a/config/osmobts/nitb/osmo-upf.cfg b/config/osmobts/nitb/osmo-upf.cfg new file mode 100644 index 0000000..d98510b --- /dev/null +++ b/config/osmobts/nitb/osmo-upf.cfg @@ -0,0 +1,15 @@ +pfcp + local-addr 192.168.0.9 +nft + # netfilter requires no specifc configuration +gtp + # if encaps/decaps of GTP to "the internet" is required, uncomment the following line: + #dev create apn0 +log stderr + logging filter all 1 + logging print extended-timestamp 1 + logging print category 1 + logging print category-hex 0 + logging print level 1 + logging print file basename last + logging level set-all info diff --git a/config/osmobts/nitb/vty b/config/osmobts/nitb/vty new file mode 100755 index 0000000..21eeed3 --- /dev/null +++ b/config/osmobts/nitb/vty @@ -0,0 +1,58 @@ +#!/usr/bin/expect -f +set vty [lindex $argv 0] +set host localhost +switch $vty { + hlr { set port 4258 } + bsc { set port 4242 } + mgw { set port 4243 } + mgw2 { + set host 127.0.0.2 + set port 4243 + } + sg { set port 4245 } + msc { set port 4254 } + sip { set port 4256 } + gg { set port 4260 } + osmo-hlr { set port 4258 } + osmo-bsc { set port 4242 } + osmo-mgw { set port 4243 } + osmo-mgw-for-bsc { set port 4243 } + osmo-mgw-for-msc { + set host 127.0.0.2 + set port 4243 + } + osmo-sgsn { set port 4245 } + osmo-msc { set port 4254 } + osmo-sip-connector { set port 4256 } + osmo-ggsn { set port 4260 } + default { set port 4242 } +} +spawn telnet localhost $port +expect ">" +send "enable\r" +expect "#" +send "logging enable\r" +expect "#" +send "logging print category 1\r" +expect "#" +send "logging print category-hex 0\r" +expect "#" +send "logging print level 1\r" +expect "#" +send "logging print file basename last\r" +expect "#" +send "logging print extended-timestamp 1\r" +expect "#" +send "logging level set-all notice\r" +expect "#" +switch $vty { + msc { + send "logging level mm info\r" + expect "#" + send "logging level cc info\r" + expect "#" + } +} +send "logging filter all 1\r" +expect "#" +interact diff --git a/config/osmobts/nitb/vty_sticky b/config/osmobts/nitb/vty_sticky new file mode 100755 index 0000000..9399512 --- /dev/null +++ b/config/osmobts/nitb/vty_sticky @@ -0,0 +1,5 @@ +#!/bin/sh +while true; do + vty $@ + sleep 3 +done diff --git a/scripts/telecom_software.sh b/scripts/telecom_software.sh index 5073ec0..46dd2f0 100644 --- a/scripts/telecom_software.sh +++ b/scripts/telecom_software.sh @@ -153,7 +153,7 @@ function Open5GS_soft_install() { } function pycrate_soft_install() { - [ -d /telecom/5G ] || mkdir -p /telecom + [ -d /telecom ] || mkdir -p /telecom cd /telecom goodecho "[+] Cloninig and installing pycrate" installfromnet "git clone https://github.com/pycrate-org/pycrate.git" @@ -161,4 +161,50 @@ function pycrate_soft_install() { python3 setup.py install } +function osmobts_suite_soft_install() { + set -e + goodecho "[+] Installing OsmoBTS suite dependencies" + installfromnet "apt-fast install -y libmnl-dev libpcsclite-dev liburing-dev libtool libgnutls28-dev libtalloc-dev libsctp-dev lksctp-tools libortp-dev dahdi-source libopenr2-dev libc-ares-dev libtonezone-dev libsqlite3-dev" + + install_lib() { + local repo_url=$1 + local repo_dir=$2 + local configure_opts=$3 + + goodecho "[+] Cloning and installing $repo_dir" + cd $osmo_src + installfromnet "git clone $repo_url" || { echo "Failed to clone $repo_dir"; exit 1; } + cd $repo_dir + autoreconf -fi || { echo "autoreconf failed for $repo_dir"; exit 1; } + ./configure $configure_opts || { echo "configure failed for $repo_dir"; exit 1; } + make -j$(nproc) || { echo "make failed for $repo_dir"; exit 1; } + #make check || { echo "make check failed for $repo_dir"; exit 1; } + make install || { echo "make install failed for $repo_dir"; exit 1; } + sudo ldconfig || { echo "ldconfig failed for $repo_dir"; exit 1; } + } + + [ -d /telecom/2G/osmocom ] || mkdir -p /telecom/2G/osmocom + cd /telecom/2G/osmocom + mkdir -p tmp/osmo/src + osmo_src=$(pwd)/tmp/osmo/src + + install_lib "https://gitea.osmocom.org/osmocom/libosmocore.git" "libosmocore" + install_lib "https://gitea.osmocom.org/osmocom/libosmo-abis.git" "libosmo-abis" + install_lib "https://gitea.osmocom.org/osmocom/libosmo-netif.git" "libosmo-netif" + install_lib "https://gitea.osmocom.org/osmocom/libosmo-sccp.git" "libosmo-sccp" + install_lib "https://gitea.osmocom.org/cellular-infrastructure/libsmpp34.git" "libsmpp34" + install_lib "https://gitea.osmocom.org/cellular-infrastructure/osmo-mgw.git" "osmo-mgw" + install_lib "https://gitea.osmocom.org/cellular-infrastructure/libasn1c.git" "libasn1c" + install_lib "https://gitea.osmocom.org/cellular-infrastructure/osmo-iuh.git" "osmo-iuh" + install_lib "https://gitea.osmocom.org/cellular-infrastructure/osmo-hlr.git" "osmo-hlr" + install_lib "https://gitea.osmocom.org/cellular-infrastructure/osmo-msc.git" "osmo-msc" "--enable-iu" + install_lib "https://gitea.osmocom.org/cellular-infrastructure/osmo-ggsn.git" "osmo-ggsn" + install_lib "https://gitea.osmocom.org/cellular-infrastructure/osmo-sgsn.git" "osmo-sgsn" "--enable-iu" + + # cleaning + cd /telecom/2G/osmocom + rm -R tmp + cp /root/config/osmobts/nitb/* . +} + ### TODO: more More! \ No newline at end of file