Ueransim docs two slices (#341)

* tutorial for ueransim with two slices

* Update README.md

* ueransim and open5gs versions updated
This commit is contained in:
Juan Pontón Rodríguez
2025-02-28 13:08:40 +01:00
committed by GitHub
parent 23f7721216
commit f48b075dc5
9 changed files with 1615 additions and 0 deletions

View File

@@ -0,0 +1,61 @@
# open5gs and ueransim with two slices
This tutorial is an adaptation of the Open5GS and UERANSIM tutorial.
The slices values were changed in the gNBs, and the NSSF and AMF configuration files were added in the config folder. Also, the SMF configuration file was modified, and the register_subscriber.sh script was updated with the new slice values.
# Deployment NGC and register subscribers
deploy the ngc core (open5gs) with:
```
docker compose -f ngc.yaml up -d
```
Register subscribers in ngc with `./register_subscriber.sh`.
# Deploy gnodeb
gnb1.yaml is configured to deploy 1 gnodeb (gnb1) and 3 ues:
```
docker compose -f gnb1.yaml up -d
```
You can use gnb2.yaml to deploy a second gnodeb (gnb2) with 3 additional ues:
```
docker compose -f gnb2.yaml up -d
```
# Test
To test ue connectivity through RAN, enter the gnb1-ues1 container:
```
docker compose -f gnb1.yaml exec ues1 /bin/bash
traceroute -i uesimtun0 google.es
ping -I uesimtun0 google.es
```
ues container will have multiple interfaces (one for each ue).
You can try each tunnel providing the flag '-i' in traceroute and '-I' in ping.
If you have deployed a second genodeb (gnb2) the command to enter in the ues container is:
```
docker compose -f gnb2.yaml exec ues2 /bin/bash
```
# Clean Up
Undeploy with:
```
docker compose -f gnb1.yaml down
docker compose -f gnb2.yaml down
docker compose -f ngc.yaml down -v
```

View File

@@ -0,0 +1,60 @@
logger:
path:
file: /opt/open5gs/var/log/open5gs/amf.log
# level: info # fatal|error|warn|info(default)|debug|trace
global:
# max:
# ue: 1024 # The number of UE can be increased depending on memory size.
# peer: 64
amf:
sbi:
server:
- dev: eth0
port: 7777
client:
# nrf:
# - uri: http://127.0.0.10:7777
scp:
- uri: http://scp:7777
ngap:
server:
- dev: eth0
metrics:
server:
- dev: eth0
port: 9090
guami:
- plmn_id:
mcc: 999
mnc: 70
amf_id:
region: 2
set: 1
tai:
- plmn_id:
mcc: 999
mnc: 70
tac: 1
plmn_support:
- plmn_id:
mcc: "999"
mnc: "70"
s_nssai:
- sd: "0x111111"
sst: "1"
- sd: "0x222222"
sst: "2"
security:
integrity_order: [NIA2, NIA1, NIA0]
ciphering_order: [NEA0, NEA1, NEA2]
network_name:
full: Open5GS
short: Next
amf_name: open5gs-amf0
time:
# t3502:
# value: 720 # 12 minutes * 60 = 720 seconds
t3512:
value: 540 # 9 minutes * 60 = 540 seconds

View File

@@ -0,0 +1,29 @@
logger:
path:
file: /opt/open5gs/var/log/open5gs/nssf.log
# level: info # fatal|error|warn|info(default)|debug|trace
global:
max:
# ue: 1024 # The number of UE can be increased depending on memory size.
# peer: 64
nssf:
sbi:
server:
- dev: eth0
port: 7777
client:
# nrf:
# - uri: http://127.0.0.10:7777
scp:
- uri: http://scp:7777
nsi:
- uri: http://nrf:7777
s_nssai:
sst: 1
sd: 0x111111
- uri: http://nrf:7777
s_nssai:
sst: 2
sd: 0x222222

View File

@@ -0,0 +1,373 @@
logger:
file:
path: /opt/open5gs/var/log/open5gs/smf.log
# level: info # fatal|error|warn|info(default)|debug|trace
global:
# max:
# ue: 1024 # The number of UE can be increased depending on memory size.
# peer: 64
smf:
sbi:
server:
- dev: eth0
port: 7777
client:
# nrf:
# - uri: http://127.0.0.10:7777
scp:
- uri: http://scp:7777
pfcp:
server:
- dev: eth0
client:
upf:
- address: upf
gtpc:
server:
- dev: eth0
gtpu:
server:
- dev: eth0
metrics:
server:
- dev: eth0
port: 9090
info:
- s_nssai:
- sst: "1"
sd: "0x111111"
dnn: "internet"
- sst: "2"
sd: "0x222222"
dnn: "internet"
tai:
- plmn_id:
mcc: 999
mnc: 70
tac: 1
session:
- subnet: 10.45.0.0/16
gateway: 10.45.0.1
dnn: internet
- subnet: 2001:db8:cafe::/48
gateway: 2001:db8:cafe::1
dns:
- 8.8.8.8
- 8.8.4.4
- 2001:4860:4860::8888
- 2001:4860:4860::8844
mtu: 1400
# p-cscf:
# - 127.0.0.1
# - ::1
ctf:
enabled: auto # auto(default)|yes|no
# This line is commented so it doesn't try to reach to the pcrf
# freeDiameter: /opt/open5gs/etc/freeDiameter/smf.conf
################################################################################
# SMF Info
################################################################################
# <SMF Selection - 5G Core only>
# 1. SMF sends SmfInfo(S-NSSAI, DNN, TAI) to the NRF
# 2. NRF responds to AMF with SmfInfo during NF-Discovery.
# 3. AMF selects SMF based on S-NSSAI, DNN and TAI in SmfInfo.
#
# Note that if there is no SmfInfo, any AMF can select this SMF.
#
# o S-NSSAI[SST:1] and DNN[internet] - At least 1 DNN is required in S-NSSAI
# info:
# - s_nssai:
# - sst: 1
# dnn:
# - internet
#
# o S-NSSAI[SST:1 SD:009000] and DNN[internet or ims]
# info:
# - s_nssai:
# - sst: 1
# sd: 009000
# dnn:
# - internet
# - ims
#
# o S-NSSAI[SST:1] and DNN[internet] and TAI[PLMN-ID:99970 TAC:1]
# info:
# - s_nssai:
# - sst: 1
# dnn:
# - internet
# tai:
# - plmn_id:
# mcc: 999
# mnc: 70
# tac: 1
#
# o If any of conditions below are met:
# - S-NSSAI[SST:1] and DNN[internet] and TAI[PLMN-ID:99970 TAC:1-9]
# - S-NSSAI[SST:2 SD:000080] and DNN[internet or ims]
# - S-NSSAI[SST:4] and DNN[internet] and TAI[PLMN-ID:99970 TAC:10-20,30-40]
# info:
# - s_nssai:
# - sst: 1
# dnn:
# - internet
# tai:
# - plmn_id:
# mcc: 999
# mnc: 70
# tac:
# - 1-9
# - s_nssai:
# - sst: 2
# sd: 000080
# dnn:
# - internet
# - ims
# - s_nssai:
# - sst: 4
# dnn:
# - internet
# tai:
# - plmn_id:
# mcc: 999
# mnc: 70
# tac:
# - 10-20
# - 30-40
#
# o Complex Example
# info:
# - s_nssai:
# - sst: 1
# dnn:
# - internet
# - sst: 1
# sd: 000080
# dnn:
# - internet
# - ims
# - sst: 1
# sd: 009000
# dnn:
# [internet, ims]
# - sst: 2
# dnn:
# - internet
# - sst: 3
# sd: 123456
# dnn:
# - internet
# tai:
# - plmn_id:
# mcc: 999
# mnc: 70
# tac: [1, 2, 3]
# - plmn_id:
# mcc: 999
# mnc: 70
# tac: 4
# - plmn_id:
# mcc: 999
# mnc: 70
# tac:
# - 5
# - 6
# - plmn_id:
# mcc: 999
# mnc: 70
# tac:
# - 100-200
# - 300-400
# - plmn_id:
# mcc: 999
# mnc: 70
# tac:
# - 500-600
# - 700-800
# - 900-1000
# - s_nssai:
# - sst: 4
# dnn:
# - internet
# tai:
# - plmn_id:
# mcc: 999
# mnc: 70
# tac: 99
#
################################################################################
# SBI Server
################################################################################
# o Override SBI address to be advertised to NRF
# sbi:
# server:
# - dev: eth0
# advertise: open5gs-smf.svc.local
#
# sbi:
# server:
# - address: localhost
# advertise:
# - 127.0.0.99
# - ::1
#
################################################################################
# SBI Client
################################################################################
# o Direct communication with NRF interaction
# sbi:
# client:
# nrf:
# - uri: http://127.0.0.10:7777
#
# o Indirect communication with delegated discovery
# sbi:
# client:
# scp:
# - uri: http://127.0.0.200:7777
#
# o Indirect communication without delegated discovery
# sbi:
# client:
# nrf:
# - uri: http://127.0.0.10:7777
# scp:
# - uri: http://127.0.0.200:7777
# discovery:
# delegated: no
#
################################################################################
# HTTPS scheme with TLS
################################################################################
# o Set as default if not individually set
# default:
# tls:
# server:
# scheme: https
# private_key: @sysconfdir@/open5gs/tls/smf.key
# cert: @sysconfdir@/open5gs/tls/smf.crt
# client:
# scheme: https
# cacert: @sysconfdir@/open5gs/tls/ca.crt
# sbi:
# server:
# - address: smf.localdomain
# client:
# nrf:
# - uri: https://nrf.localdomain
#
# o Add client TLS verification
# default:
# tls:
# server:
# scheme: https
# private_key: @sysconfdir@/open5gs/tls/smf.key
# cert: @sysconfdir@/open5gs/tls/smf.crt
# verify_client: true
# verify_client_cacert: @sysconfdir@/open5gs/tls/ca.crt
# client:
# scheme: https
# cacert: @sysconfdir@/open5gs/tls/ca.crt
# client_private_key: @sysconfdir@/open5gs/tls/smf.key
# client_cert: @sysconfdir@/open5gs/tls/smf.crt
# sbi:
# server:
# - address: smf.localdomain
# client:
# nrf:
# - uri: https://nrf.localdomain
#
################################################################################
# PFCP Server
################################################################################
# o Override PFCP address to be advertised to UPF in PFCP association
# pfcp:
# server:
# - dev: eth0
# advertise: open5gs-smf.svc.local
#
################################################################################
# PFCP Client
################################################################################
# o UPF selection by eNodeB TAC
# (either single TAC or multiple TACs, DECIMAL representation)
# pfcp:
# client:
# upf:
# - address: 127.0.0.7
# tac: 1
# - address: 127.0.0.12
# tac: [3,5,8]
#
# o UPF selection by UE's DNN/APN (either single DNN/APN or multiple DNNs/APNs)
# pfcp:
# client:
# upf:
# - address: 127.0.0.7
# dnn: ims
# - address: 127.0.0.12
# dnn: [internet, web]
#
# o UPF selection by CellID(e_cell_id: 28bit, nr_cell_id: 36bit)
# (either single enb_id or multiple enb_ids, HEX representation)
# pfcp:
# client:
# upf:
# - address: 127.0.0.7
# e_cell_id: 463
# - address: 127.0.0.12
# nr_cell_id: [123456789, 9413]
#
################################################################################
# GTP-C Server
################################################################################
# o Listen on IPv4 and IPv6
# gtpc:
# server:
# - address: 127.0.0.4
# - address: fd69:f21d:873c:fa::3
#
################################################################################
# GTP-U Server
################################################################################
# o Listen on IPv4 and IPv6
# gtpu:
# server:
# - address: 127.0.0.4
# - address: ::1
#
################################################################################
# 3GPP Specification
################################################################################
# o Specific DNN/APN(e.g 'ims') uses 10.46.0.1/16, 2001:db8:babe::1/48
# (If the UE has unknown DNN/APN(not internet/ims), SMF/UPF will crash.)
# session:
# - subnet: 10.45.0.1/16
# dnn: internet
# - subnet: 2001:db8:cafe::1/48
# dnn: internet
# - subnet: 10.46.0.1/16
# dnn: ims
# - subnet: 2001:db8:babe::1/48
# dnn: ims
#
# o Pool Range
# session:
# - subnet: 10.45.0.1/16
# range:
# - 10.45.0.100-10.45.0.200
# - 10.45.1.100-
# - -10.45.0.200
# - subnet: 2001:db8:cafe::1/48
# range:
# - 2001:db8:cafe:a0::0-2001:db8:cafe:b0::0
# - 2001:db8:cafe:c0::0-2001:db8:cafe:d0::0
#
# o Security Indication(5G Core only)
# security_indication:
# integrity_protection_indication: required|preferred|not-needed
# confidentiality_protection_indication: required|preferred|not-needed
# maximum_integrity_protected_data_rate_uplink: bitrate64kbs|maximum-UE-rate
# maximum_integrity_protected_data_rate_downlink: bitrate64kbs|maximum-UE-rate

View File

@@ -0,0 +1,32 @@
version: '3'
services:
gnb1:
image: gradiant/ueransim:3.2.7
container_name: gnb1
command:
- gnb
environment:
AMF_HOSTNAME: amf
GNB_HOSTNAME: gnb1
TAC: '1'
MCC: '999'
MNC: '70'
SST: '1'
SD: '0x111111'
ues1:
image: gradiant/ueransim:3.2.7
command: ['ue','-n','3']
cap_add:
- all
privileged: true
environment:
GNB_HOSTNAME: gnb1
APN: internet
MSISDN: '0000000001'
MCC: '999'
MNC: '70'
KEY: '465B5CE8B199B49FAA5F0A2EE238A6BC'
OP_TYPE: OPC
OP: 'E8ED289DEBA952E4283B54E88E6183CA'
SST: '1'
SD: '0x111111'

View File

@@ -0,0 +1,33 @@
version: '3'
services:
gnb2:
image: gradiant/ueransim:3.2.7
container_name: gnb2
command:
- gnb
environment:
AMF_HOSTNAME: amf
GNB_HOSTNAME: gnb2
TAC: '1'
MCC: '999'
MNC: '70'
SST: '2'
SD: '0x222222'
ues2:
image: gradiant/ueransim:3.2.7
command: ['ue','-n','3']
cap_add:
- all
privileged: true
environment:
GNB_HOSTNAME: gnb2
APN: internet
MSISDN: '0000000011'
MCC: '999'
MNC: '70'
KEY: '465B5CE8B199B49FAA5F0A2EE238A6BC'
OP_TYPE: OPC
OP: 'E8ED289DEBA952E4283B54E88E6183CA'
SST: '2'
SD: '0x222222'

View File

@@ -0,0 +1,107 @@
version: '3'
services:
mongo:
image: mongo
environment:
MONGO_INITDB_DATABASE: open5gs
amf:
image: gradiant/open5gs:2.7.2
volumes:
- ./config/amf.yaml:/opt/open5gs/etc/open5gs/amf.yaml
command:
- open5gs-amfd
restart: on-failure
ausf:
image: gradiant/open5gs:2.7.2
command:
- open5gs-ausfd
restart: on-failure
bsf:
image: gradiant/open5gs:2.7.2
command:
- open5gs-bsfd
restart: on-failure
nrf:
image: gradiant/open5gs:2.7.2
command: open5gs-nrfd
restart: on-failure
nssf:
image: gradiant/open5gs:2.7.2
volumes:
- ./config/nssf.yaml:/opt/open5gs/etc/open5gs/nssf.yaml
command: open5gs-nssfd
restart: on-failure
pcf:
image: gradiant/open5gs:2.7.2
command:
- open5gs-pcfd
environment:
DB_URI: mongodb://mongo/open5gs
restart: on-failure
scp:
image: gradiant/open5gs:2.7.2
command: open5gs-scpd
environment:
DB_URI: mongodb://mongo/open5gs
restart: on-failure
smf:
image: gradiant/open5gs:2.7.2
#It is necessary to mount the configuration file if pcfr is not deployed
volumes:
- ./config/smf.yaml:/opt/open5gs/etc/open5gs/smf.yaml
restart: on-failure
command: open5gs-smfd
udm:
image: gradiant/open5gs:2.7.2
restart: on-failure
command:
- open5gs-udmd
udr:
image: gradiant/open5gs:2.7.2
restart: on-failure
environment:
DB_URI: mongodb://mongo/open5gs
command:
- open5gs-udrd
upf:
image: gradiant/open5gs:2.7.2
user: root
command:
- open5gs-upfd
cap_add:
- all
privileged: true
restart: on-failure
# environment:
# ENABLE_NAT: "false"
ports:
- 2152:2152
webui:
image: gradiant/open5gs-webui:2.7.2
restart: on-failure
environment:
DB_URI: mongodb://mongo/open5gs
NODE_ENV: dev
ports:
- 9999:9999
# portainer:
# image: portainer/portainer-ce
# ports:
# - 9000:9000
# volumes:
# - /var/run/docker.sock:/var/run/docker.sock

View File

@@ -0,0 +1,856 @@
#!/bin/bash
version=0.10.3
display_help() {
echo "open5gs-dbctl: Open5GS Database Configuration Tool ($version)"
echo "FLAGS: --db_uri=mongodb://localhost"
echo "COMMANDS:" >&2
echo " add {imsi key opc}: adds a user to the database with default values"
echo " add {imsi ip key opc}: adds a user to the database with default values and a IPv4 address for the UE"
echo " addT1 {imsi key opc}: adds a user to the database with 3 differents apns"
echo " addT1 {imsi ip key opc}: adds a user to the database with 3 differents apns and the same IPv4 address for the each apn"
echo " remove {imsi}: removes a user from the database"
echo " reset: WIPES OUT the database and restores it to an empty default"
echo " static_ip {imsi ip4}: adds a static IP assignment to an already-existing user"
echo " static_ip6 {imsi ip6}: adds a static IPv6 assignment to an already-existing user"
echo " type {imsi type}: changes the PDN-Type of the first PDN: 1 = IPv4, 2 = IPv6, 3 = IPv4v6"
echo " help: displays this message and exits"
echo " default values are as follows: APN \"internet\", dl_bw/ul_bw 1 Gbps, PGW address is 127.0.0.3, IPv4 only"
echo " add_ue_with_apn {imsi key opc apn}: adds a user to the database with a specific apn,"
echo " add_ue_with_slice {imsi key opc apn sst sd}: adds a user to the database with a specific apn, sst and sd"
echo " update_apn {imsi apn slice_num}: adds an APN to the slice number slice_num of an existent UE"
echo " update_slice {imsi apn sst sd}: adds an slice to an existent UE"
echo " showall: shows the list of subscriber in the db"
echo " showpretty: shows the list of subscriber in the db in a pretty json tree format"
echo " showfiltered: shows {imsi key opc apn ip} information of subscriber"
echo " ambr_speed {imsi dl_value dl_unit ul_value ul_unit}: Change AMBR speed from a specific user and the unit values are \"[0=bps 1=Kbps 2=Mbps 3=Gbps 4=Tbps ]\""
echo " subscriber_status {imsi subscriber_status_val={0,1} operator_determined_barring={0..8}}: Change TS 29.272 values for Subscriber-Status (7.3.29) and Operator-Determined-Barring (7.3.30)"
}
while test $# -gt 0; do
case "$1" in
--db_uri*)
DB_URI=`echo $1 | sed -e 's/^[^=]*=//g'`
shift
;;
*)
break
;;
esac
done
DB_URI="${DB_URI:-mongodb://localhost/open5gs}"
if [ "$#" -lt 1 ]; then
display_help
exit 1
fi
if [ "$1" = "help" ]; then
display_help
exit 1
fi
if [ "$1" = "add" ]; then
if [ "$#" -eq 4 ]; then
IMSI=$2
KI=$3
OPC=$4
mongosh --eval "db.subscribers.insertOne(
{
\"_id\": new ObjectId(),
\"schema_version\": NumberInt(1),
\"imsi\": \"$IMSI\",
\"msisdn\": [],
\"imeisv\": [],
\"mme_host\": [],
\"mm_realm\": [],
\"purge_flag\": [],
\"slice\":[
{
\"sst\": NumberInt(1),
\"default_indicator\": true,
\"session\": [
{
\"name\" : \"internet\",
\"type\" : NumberInt(3),
\"qos\" :
{ \"index\": NumberInt(9),
\"arp\":
{
\"priority_level\" : NumberInt(8),
\"pre_emption_capability\": NumberInt(1),
\"pre_emption_vulnerability\": NumberInt(2)
}
},
\"ambr\":
{
\"downlink\":
{
\"value\": NumberInt(1000000000),
\"unit\": NumberInt(0)
},
\"uplink\":
{
\"value\": NumberInt(1000000000),
\"unit\": NumberInt(0)
}
},
\"pcc_rule\": [],
\"_id\": new ObjectId(),
}],
\"_id\": new ObjectId(),
}],
\"security\":
{
\"k\" : \"$KI\",
\"op\" : null,
\"opc\" : \"$OPC\",
\"amf\" : \"8000\",
},
\"ambr\" :
{
\"downlink\" : { \"value\": NumberInt(1000000000), \"unit\": NumberInt(0)},
\"uplink\" : { \"value\": NumberInt(1000000000), \"unit\": NumberInt(0)}
},
\"access_restriction_data\": 32,
\"network_access_mode\": 0,
\"subscriber_status\": 0,
\"operator_determined_barring\": 0,
\"subscribed_rau_tau_timer\": 12,
\"__v\": 0
}
);" $DB_URI
exit $?
fi
if [ "$#" -eq 5 ]; then
IMSI=$2
IP=$3
KI=$4
OPC=$5
mongosh --eval "db.subscribers.insertOne(
{
\"_id\": new ObjectId(),
\"schema_version\": NumberInt(1),
\"imsi\": \"$IMSI\",
\"msisdn\": [],
\"imeisv\": [],
\"mme_host\": [],
\"mm_realm\": [],
\"purge_flag\": [],
\"slice\":[
{
\"sst\": NumberInt(1),
\"default_indicator\": true,
\"session\": [
{
\"name\" : \"internet\",
\"type\" : NumberInt(3),
\"qos\" :
{ \"index\": NumberInt(9),
\"arp\":
{
\"priority_level\" : NumberInt(8),
\"pre_emption_capability\": NumberInt(1),
\"pre_emption_vulnerability\": NumberInt(2)
}
},
\"ambr\":
{
\"downlink\":
{
\"value\": NumberInt(1000000000),
\"unit\": NumberInt(0)
},
\"uplink\":
{
\"value\": NumberInt(1000000000),
\"unit\": NumberInt(0)
}
},
\"ue\":
{
\"ipv4\": \"$IP\"
},
\"pcc_rule\": [],
\"_id\": new ObjectId(),
}],
\"_id\": new ObjectId(),
}],
\"security\":
{
\"k\" : \"$KI\",
\"op\" : null,
\"opc\" : \"$OPC\",
\"amf\" : \"8000\",
},
\"ambr\" :
{
\"downlink\" : { \"value\": NumberInt(1000000000), \"unit\": NumberInt(0)},
\"uplink\" : { \"value\": NumberInt(1000000000), \"unit\": NumberInt(0)}
},
\"access_restriction_data\": 32,
\"network_access_mode\": 0,
\"subscriber_status\": 0,
\"operator_determined_barring\": 0,
\"subscribed_rau_tau_timer\": 12,
\"__v\": 0
}
);" $DB_URI
exit $?
fi
echo "open5gs-dbctl: incorrect number of args, format is \"open5gs-dbctl add imsi key opc\""
exit 1
fi
if [ "$1" = "addT1" ]; then
if [ "$#" -eq 4 ]; then
IMSI=$2
KI=$3
OPC=$4
mongosh --eval "db.subscribers.insertOne(
{
\"_id\": new ObjectId(),
\"schema_version\": NumberInt(1),
\"imsi\": \"$IMSI\",
\"msisdn\": [],
\"imeisv\": [],
\"mme_host\": [],
\"mm_realm\": [],
\"purge_flag\": [],
\"slice\":[
{
\"sst\": NumberInt(1),
\"default_indicator\": true,
\"session\": [
{
\"name\" : \"internet\",
\"type\" : NumberInt(3),
\"qos\" :
{ \"index\": NumberInt(9),
\"arp\":
{
\"priority_level\" : NumberInt(8),
\"pre_emption_capability\": NumberInt(1),
\"pre_emption_vulnerability\": NumberInt(2)
}
},
\"ambr\":
{
\"downlink\":
{
\"value\": NumberInt(1000000000),
\"unit\": NumberInt(0)
},
\"uplink\":
{
\"value\": NumberInt(1000000000),
\"unit\": NumberInt(0)
}
},
\"pcc_rule\": [],
\"_id\": new ObjectId(),
},{
\"name\" : \"internet1\",
\"type\" : NumberInt(3),
\"qos\" :
{ \"index\": NumberInt(9),
\"arp\":
{
\"priority_level\" : NumberInt(8),
\"pre_emption_capability\": NumberInt(1),
\"pre_emption_vulnerability\": NumberInt(2)
}
},
\"ambr\":
{
\"downlink\":
{
\"value\": NumberInt(1000000000),
\"unit\": NumberInt(0)
},
\"uplink\":
{
\"value\": NumberInt(1000000000),
\"unit\": NumberInt(0)
}
},
\"pcc_rule\": [],
\"_id\": new ObjectId(),
},{
\"name\" : \"internet2\",
\"type\" : NumberInt(3),
\"qos\" :
{ \"index\": NumberInt(9),
\"arp\":
{
\"priority_level\" : NumberInt(8),
\"pre_emption_capability\": NumberInt(1),
\"pre_emption_vulnerability\": NumberInt(2)
}
},
\"ambr\":
{
\"downlink\":
{
\"value\": NumberInt(1000000000),
\"unit\": NumberInt(0)
},
\"uplink\":
{
\"value\": NumberInt(1000000000),
\"unit\": NumberInt(0)
}
},
\"pcc_rule\": [],
\"_id\": new ObjectId(),
}
],
\"_id\": new ObjectId(),
}],
\"security\":
{
\"k\" : \"$KI\",
\"op\" : null,
\"opc\" : \"$OPC\",
\"amf\" : \"8000\",
},
\"ambr\" :
{
\"downlink\" : { \"value\": NumberInt(1000000000), \"unit\": NumberInt(0)},
\"uplink\" : { \"value\": NumberInt(1000000000), \"unit\": NumberInt(0)}
},
\"access_restriction_data\": 32,
\"network_access_mode\": 0,
\"subscriber_status\": 0,
\"operator_determined_barring\": 0,
\"subscribed_rau_tau_timer\": 12,
\"__v\": 0
}
);" $DB_URI
exit $?
fi
if [ "$#" -eq 5 ]; then
IMSI=$2
IP=$3
KI=$4
OPC=$5
mongosh --eval "db.subscribers.insertOne(
{
\"_id\": new ObjectId(),
\"schema_version\": NumberInt(1),
\"imsi\": \"$IMSI\",
\"msisdn\": [],
\"imeisv\": [],
\"mme_host\": [],
\"mm_realm\": [],
\"purge_flag\": [],
\"slice\":[
{
\"sst\": NumberInt(1),
\"default_indicator\": true,
\"session\": [
{
\"name\" : \"internet\",
\"type\" : NumberInt(3),
\"qos\" :
{ \"index\": NumberInt(9),
\"arp\":
{
\"priority_level\" : NumberInt(8),
\"pre_emption_capability\": NumberInt(1),
\"pre_emption_vulnerability\": NumberInt(2)
}
},
\"ambr\":
{
\"downlink\":
{
\"value\": NumberInt(1000000000),
\"unit\": NumberInt(0)
},
\"uplink\":
{
\"value\": NumberInt(1000000000),
\"unit\": NumberInt(0)
}
},
\"ue\":
{
\"ipv4\": \"$IP\"
},
\"pcc_rule\": [],
\"_id\": new ObjectId(),
},{
\"name\" : \"internet1\",
\"type\" : NumberInt(3),
\"qos\" :
{ \"index\": NumberInt(9),
\"arp\":
{
\"priority_level\" : NumberInt(8),
\"pre_emption_capability\": NumberInt(1),
\"pre_emption_vulnerability\": NumberInt(2)
}
},
\"ambr\":
{
\"downlink\":
{
\"value\": NumberInt(1000000000),
\"unit\": NumberInt(0)
},
\"uplink\":
{
\"value\": NumberInt(1000000000),
\"unit\": NumberInt(0)
}
},
\"ue\":
{
\"ipv4\": \"$IP\"
},
\"pcc_rule\": [],
\"_id\": new ObjectId(),
},{
\"name\" : \"internet2\",
\"type\" : NumberInt(3),
\"qos\" :
{ \"index\": NumberInt(9),
\"arp\":
{
\"priority_level\" : NumberInt(8),
\"pre_emption_capability\": NumberInt(1),
\"pre_emption_vulnerability\": NumberInt(2)
}
},
\"ambr\":
{
\"downlink\":
{
\"value\": NumberInt(1000000000),
\"unit\": NumberInt(0)
},
\"uplink\":
{
\"value\": NumberInt(1000000000),
\"unit\": NumberInt(0)
}
},
\"ue\":
{
\"ipv4\": \"$IP\"
},
\"pcc_rule\": [],
\"_id\": new ObjectId(),
}
],
\"_id\": new ObjectId(),
}],
\"security\":
{
\"k\" : \"$KI\",
\"op\" : null,
\"opc\" : \"$OPC\",
\"amf\" : \"8000\",
},
\"ambr\" :
{
\"downlink\" : { \"value\": NumberInt(1000000000), \"unit\": NumberInt(0)},
\"uplink\" : { \"value\": NumberInt(1000000000), \"unit\": NumberInt(0)}
},
\"access_restriction_data\": 32,
\"network_access_mode\": 0,
\"subscriber_status\": 0,
\"operator_determined_barring\": 0,
\"subscribed_rau_tau_timer\": 12,
\"__v\": 0
}
);" $DB_URI
exit $?
fi
echo "open5gs-dbctl: incorrect number of args, format is \"open5gs-dbctl add imsi key opc\""
exit 1
fi
if [ "$1" = "remove" ]; then
if [ "$#" -ne 2 ]; then
echo "open5gs-dbctl: incorrect number of args, format is \"open5gs-dbctl remove imsi\""
exit 1
fi
IMSI=$2
mongosh --eval "db.subscribers.deleteOne({\"imsi\": \"$IMSI\"});" $DB_URI
exit $?
fi
if [ "$1" = "reset" ]; then
if [ "$#" -ne 1 ]; then
echo "open5gs-dbctl: incorrect number of args, format is \"open5gs-dbctl reset\""
exit 1
fi
mongosh --eval "db.subscribers.deleteMany({});" $DB_URI
exit $?
fi
if [ "$1" = "static_ip" ]; then
if [ "$#" -ne 3 ]; then
echo "open5gs-dbctl: incorrect number of args, format is \"open5gs-dbctl static_ip imsi ip\""
exit 1
fi
IMSI=$2
IP=$3
mongosh --eval "db.subscribers.updateOne({\"imsi\": \"$IMSI\"},{\$set: { \"slice.0.session.0.ue.ipv4\": \"$IP\" }});" $DB_URI
exit $?
fi
if [ "$1" = "static_ip6" ]; then
if [ "$#" -ne 3 ]; then
echo "open5gs-dbctl: incorrect number of args, format is \"open5gs-dbctl static_ip6 imsi ip\""
exit 1
fi
IMSI=$2
IP=$3
mongosh --eval "db.subscribers.updateOne({\"imsi\": \"$IMSI\"},{\$set: { \"slice.0.session.0.ue.ipv6\": \"$IP\" }});" $DB_URI
exit $?
fi
if [ "$1" = "type" ]; then
if [ "$#" -ne 3 ]; then
echo "open5gs-dbctl: incorrect number of args, format is \"open5gs-dbctl type imsi type\""
exit 1
fi
IMSI=$2
TYPE=$3
mongosh --eval "db.subscribers.updateOne({\"imsi\": \"$IMSI\"},{\$set: { \"slice.0.session.0.type\": NumberInt($TYPE) }});" $DB_URI
exit $?
fi
if [ "$1" = "add_ue_with_apn" ]; then
if [ "$#" -eq 5 ]; then
IMSI=$2
KI=$3
OPC=$4
APN=$5
mongosh --eval "db.subscribers.insertOne(
{
\"_id\": new ObjectId(),
\"schema_version\": NumberInt(1),
\"imsi\": \"$IMSI\",
\"msisdn\": [],
\"imeisv\": [],
\"mme_host\": [],
\"mm_realm\": [],
\"purge_flag\": [],
\"slice\":[
{
\"sst\": NumberInt(1),
\"default_indicator\": true,
\"session\": [
{
\"name\" : \"$APN\",
\"type\" : NumberInt(3),
\"qos\" :
{ \"index\": NumberInt(9),
\"arp\":
{
\"priority_level\" : NumberInt(8),
\"pre_emption_capability\": NumberInt(1),
\"pre_emption_vulnerability\": NumberInt(2)
}
},
\"ambr\":
{
\"downlink\":
{
\"value\": NumberInt(1000000000),
\"unit\": NumberInt(0)
},
\"uplink\":
{
\"value\": NumberInt(1000000000),
\"unit\": NumberInt(0)
}
},
\"pcc_rule\": [],
\"_id\": new ObjectId(),
}],
\"_id\": new ObjectId(),
}],
\"security\":
{
\"k\" : \"$KI\",
\"op\" : null,
\"opc\" : \"$OPC\",
\"amf\" : \"8000\",
},
\"ambr\" :
{
\"downlink\" : { \"value\": NumberInt(1000000000), \"unit\": NumberInt(0)},
\"uplink\" : { \"value\": NumberInt(1000000000), \"unit\": NumberInt(0)}
},
\"access_restriction_data\": 32,
\"network_access_mode\": 0,
\"subscriber_status\": 0,
\"operator_determined_barring\": 0,
\"subscribed_rau_tau_timer\": 12,
\"__v\": 0
}
);" $DB_URI
exit $?
fi
echo "open5gs-dbctl: incorrect number of args, format is \"open5gs-dbctl add_ue_with_apn imsi key opc apn\""
exit 1
fi
if [ "$1" = "add_ue_with_slice" ]; then
if [ "$#" -eq 7 ]; then
IMSI=$2
KI=$3
OPC=$4
APN=$5
SST=$6
SD=$7
mongosh --eval "db.subscribers.insertOne(
{
\"_id\": new ObjectId(),
\"schema_version\": NumberInt(1),
\"imsi\": \"$IMSI\",
\"msisdn\": [],
\"imeisv\": [],
\"mme_host\": [],
\"mm_realm\": [],
\"purge_flag\": [],
\"slice\":[
{
\"sst\": NumberInt($SST),
\"sd\": \"$SD\",
\"default_indicator\": true,
\"session\": [
{
\"name\" : \"$APN\",
\"type\" : NumberInt(3),
\"qos\" :
{ \"index\": NumberInt(9),
\"arp\":
{
\"priority_level\" : NumberInt(8),
\"pre_emption_capability\": NumberInt(1),
\"pre_emption_vulnerability\": NumberInt(2)
}
},
\"ambr\":
{
\"downlink\":
{
\"value\": NumberInt(1000000000),
\"unit\": NumberInt(0)
},
\"uplink\":
{
\"value\": NumberInt(1000000000),
\"unit\": NumberInt(0)
}
},
\"pcc_rule\": [],
\"_id\": new ObjectId(),
}],
\"_id\": new ObjectId(),
}],
\"security\":
{
\"k\" : \"$KI\",
\"op\" : null,
\"opc\" : \"$OPC\",
\"amf\" : \"8000\",
},
\"ambr\" :
{
\"downlink\" : { \"value\": NumberInt(1000000000), \"unit\": NumberInt(0)},
\"uplink\" : { \"value\": NumberInt(1000000000), \"unit\": NumberInt(0)}
},
\"access_restriction_data\": 32,
\"network_access_mode\": 0,
\"subscriber_status\": 0,
\"operator_determined_barring\": 0,
\"subscribed_rau_tau_timer\": 12,
\"__v\": 0
}
);" $DB_URI
exit $?
fi
echo "open5gs-dbctl: incorrect number of args, format is \"open5gs-dbctl add_ue_with_slice imsi key opc apn sst sd\""
exit 1
fi
if [ "$1" = "update_apn" ]; then
if [ "$#" -eq 4 ]; then
IMSI=$2
APN=$3
SLICE_NUM=$4
mongosh --eval "db.subscribers.updateOne({ \"imsi\": \"$IMSI\"},
{\$push: { \"slice.$SLICE_NUM.session\":
{
\"name\" : \"$APN\",
\"type\" : NumberInt(3),
\"_id\" : new ObjectId(),
\"pcc_rule\" : [],
\"ambr\" :
{
\"uplink\" : { \"value\": NumberInt(1), \"unit\" : NumberInt(3) },
\"downlink\" : { \"value\": NumberInt(1), \"unit\" : NumberInt(3) },
},
\"qos\" :
{
\"index\" : NumberInt(9),
\"arp\" :
{
\"priority_level\" : NumberInt(8),
\"pre_emption_capability\" : NumberInt(1),
\"pre_emption_vulnerability\" : NumberInt(1),
},
},
}
}
});" $DB_URI
exit $?
fi
echo "open5gs-dbctl: incorrect number of args, format is \"open5gs-dbctl update_apn imsi apn num_slice\""
exit 1
fi
if [ "$1" = "update_slice" ]; then
if [ "$#" -eq 5 ]; then
IMSI=$2
APN=$3
SST=$4
SD=$5
mongosh --eval "db.subscribers.updateOne({ \"imsi\": \"$IMSI\"},
{\$push: { \"slice\":
{
\"sst\" : NumberInt($SST),
\"sd\" : \"$SD\",
\"default_indicator\" : false,
\"_id\" : new ObjectId(),
\"session\" :
[{
\"name\" : \"$APN\",
\"type\" : NumberInt(3),
\"_id\" : new ObjectId(),
\"pcc_rule\" : [],
\"ambr\" :
{
\"uplink\" : { \"value\": NumberInt(1), \"unit\" : NumberInt(3) },
\"downlink\" : { \"value\": NumberInt(1), \"unit\" : NumberInt(3) },
},
\"qos\" :
{
\"index\" : NumberInt(9),
\"arp\" :
{
\"priority_level\" : NumberInt(8),
\"pre_emption_capability\" : NumberInt(1),
\"pre_emption_vulnerability\" : NumberInt(1),
},
},
}]
}
}
});" $DB_URI
exit $?
fi
echo "open5gs-dbctl: incorrect number of args, format is \"open5gs-dbctl update_slice imsi apn sst sd\""
exit 1
fi
if [ "$1" = "subscriber_status" ]; then
if [ "$#" -eq 4 ]; then
IMSI=$2
SUB_STATUS=$3
OP_DET_BARRING=$4
mongosh --eval "db.subscribers.updateOne({ \"imsi\": \"$IMSI\"},
{\$set: { \"subscriber_status\": $SUB_STATUS,
\"operator_determined_barring\": $OP_DET_BARRING
}
});" $DB_URI
exit $?
fi
echo "open5gs-dbctl: incorrect number of args, format is \"open5gs-dbctl subscriber_status imsi subscriber_status_val={0,1} operator_determined_barring={0..8}"
exit 1
fi
if [ "$1" = "showall" ]; then
mongosh --eval "db.subscribers.find()" $DB_URI
exit $?
fi
if [ "$1" = "showpretty" ]; then
mongosh --eval "db.subscribers.find().pretty()" $DB_URI
exit $?
fi
if [ "$1" = "showfiltered" ]; then
mongosh --eval "db.subscribers.find({},{'_id':0,'imsi':1,'security.k':1, 'security.opc':1,'slice.session.name':1,'slice.session.ue.ipv4':1})" $DB_URI
exit $?
fi
if [ "$1" = "ambr_speed" ]; then
if [ "$#" -eq 6 ]; then
IMSI=$2
DL_VALUE=$3
DL_UNIT=$4
UL_VALUE=$5
UL_UNIT=$6
mongosh --eval "db.subscribers.updateOne({\"imsi\": \"$IMSI\"},
{\$set: {
\"ambr\" : {
\"downlink\" : {
\"value\" : NumberInt($DL_VALUE),
\"unit\" : NumberInt($DL_UNIT)
},
\"uplink\" :{
\"value\": NumberInt($UL_VALUE),
\"unit\" : NumberInt($UL_UNIT)
}
},
\"slice.0.session.0.ambr\": {
\"downlink\" : {
\"value\" : NumberInt($DL_VALUE),
\"unit\" : NumberInt($DL_UNIT)
},
\"uplink\" :{
\"value\": NumberInt($UL_VALUE),
\"unit\" : NumberInt($UL_UNIT)
}
}
}
});" $DB_URI
exit $?
fi
echo "open5gs-dbctl: incorrect number of args, format is \"open5gs-dbctl ambr_speed imsi dl_value dl_unit ul_value ul_unit dl is for download and ul is for upload and the unit values are[0=bps 1=Kbps 2=Mbps 3=Gbps 4=Tbps ] \""
exit 1
fi
display_help

View File

@@ -0,0 +1,64 @@
#!/bin/bash
MONGO_CONTAINER=open5gs-and-ueransim-two-slices-mongo-1
: 'open5gs-dbctl: Open5GS Database Configuration Tool (0.10.3)
FLAGS: --db_uri=mongodb://localhost
COMMANDS: >&2
echo "open5gs-dbctl: Open5GS Database Configuration Tool ($version)"
echo "FLAGS: --db_uri=mongodb://localhost"
echo "COMMANDS:" >&2
echo " add {imsi key opc}: adds a user to the database with default values"
echo " add {imsi ip key opc}: adds a user to the database with default values and a IPv4 address for the UE"
echo " addT1 {imsi key opc}: adds a user to the database with 3 differents apns"
echo " addT1 {imsi ip key opc}: adds a user to the database with 3 differents apns and the same IPv4 address for the each apn"
echo " remove {imsi}: removes a user from the database"
echo " reset: WIPES OUT the database and restores it to an empty default"
echo " static_ip {imsi ip4}: adds a static IP assignment to an already-existing user"
echo " static_ip6 {imsi ip6}: adds a static IPv6 assignment to an already-existing user"
echo " type {imsi type}: changes the PDN-Type of the first PDN: 1 = IPv4, 2 = IPv6, 3 = IPv4v6"
echo " help: displays this message and exits"
echo " default values are as follows: APN \"internet\", dl_bw/ul_bw 1 Gbps, PGW address is 127.0.0.3, IPv4 only"
echo " add_ue_with_apn {imsi key opc apn}: adds a user to the database with a specific apn,"
echo " add_ue_with_slice {imsi key opc apn sst sd}: adds a user to the database with a specific apn, sst and sd"
echo " update_apn {imsi apn slice_num}: adds an APN to the slice number slice_num of an existent UE"
echo " update_slice {imsi apn sst sd}: adds an slice to an existent UE"
echo " showall: shows the list of subscriber in the db"
echo " showpretty: shows the list of subscriber in the db in a pretty json tree format"
echo " showfiltered: shows {imsi key opc apn ip} information of subscriber"
echo " ambr_speed {imsi dl_value dl_unit ul_value ul_unit}: Change AMBR speed from a specific user and the unit values are \"[0=bps 1=Kbps 2=Mbps 3=Gbps 4=Tbps ]\""
echo " subscriber_status {imsi subscriber_status_val={0,1} operator_determined_barring={0..8}}: Change TS 29.272 values for Subscriber-Status (7.3.29) and Operator-Determined-Barring (7.3.30)"
}
'
docker cp open5gs-dbctl $MONGO_CONTAINER:/
docker run -ti --rm \
--net open5gs-and-ueransim-two-slices_default \
-e DB_URI=mongodb://$MONGO_CONTAINER/open5gs \
gradiant/open5gs-dbctl:0.10.3 "open5gs-dbctl add_ue_with_slice 999700000000001 465B5CE8B199B49FAA5F0A2EE238A6BC E8ED289DEBA952E4283B54E88E6183CA internet 1 0x111111"
docker run -ti --rm \
--net open5gs-and-ueransim-two-slices_default \
-e DB_URI=mongodb://$MONGO_CONTAINER/open5gs \
gradiant/open5gs-dbctl:0.10.3 "open5gs-dbctl add_ue_with_slice 999700000000002 465B5CE8B199B49FAA5F0A2EE238A6BC E8ED289DEBA952E4283B54E88E6183CA internet 1 0x111111"
docker run -ti --rm \
--net open5gs-and-ueransim-two-slices_default \
-e DB_URI=mongodb://$MONGO_CONTAINER/open5gs \
gradiant/open5gs-dbctl:0.10.3 "open5gs-dbctl add_ue_with_slice 999700000000003 465B5CE8B199B49FAA5F0A2EE238A6BC E8ED289DEBA952E4283B54E88E6183CA internet 1 0x111111"
docker run -ti --rm \
--net open5gs-and-ueransim-two-slices_default \
-e DB_URI=mongodb://$MONGO_CONTAINER/open5gs \
gradiant/open5gs-dbctl:0.10.3 "open5gs-dbctl add_ue_with_slice 999700000000011 465B5CE8B199B49FAA5F0A2EE238A6BC E8ED289DEBA952E4283B54E88E6183CA internet 2 0x222222"
docker run -ti --rm \
--net open5gs-and-ueransim-two-slices_default \
-e DB_URI=mongodb://$MONGO_CONTAINER/open5gs \
gradiant/open5gs-dbctl:0.10.3 "open5gs-dbctl add_ue_with_slice 999700000000012 465B5CE8B199B49FAA5F0A2EE238A6BC E8ED289DEBA952E4283B54E88E6183CA internet 2 0x222222"
docker run -ti --rm \
--net open5gs-and-ueransim-two-slices_default \
-e DB_URI=mongodb://$MONGO_CONTAINER/open5gs \
gradiant/open5gs-dbctl:0.10.3 "open5gs-dbctl add_ue_with_slice 999700000000013 465B5CE8B199B49FAA5F0A2EE238A6BC E8ED289DEBA952E4283B54E88E6183CA internet 2 0x222222"