Skip to content

Commit a7d976f

Browse files
Simewufjcintron
andauthored
Tag v1.7.1
* Make Data Network Name (DNN) configurable at the slice level * Improve Open5GS install reliability and service detection * Tag v1.7.1 --------- Co-authored-by: fjcintron <fernando.cintron@nist.gov>
1 parent a98a369 commit a7d976f

180 files changed

Lines changed: 25107 additions & 3680 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

5G_Core_Network/Additional_Cores_5GDeploy/full_install.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,8 @@ echo "Starting installation of 5G Core Deployment Helper (5gdeploy)..."
203203
--gtp5g-version v0.9.16 \
204204
--oai-fed-version v2.2.0 \
205205
--oai-nwdaf-version 6a1408c9be6f5cf0ddb6c1f1b527a04e36205471 \
206-
--open5gs-dbctl-version v2.7.6 \
207-
--open5gs-version 2.7.6 \
206+
--open5gs-dbctl-version v2.7.7 \
207+
--open5gs-version 2.7.7 \
208208
--packetrusher-version 80a7f4bc63d9563a8ec58ba126440d94018a35a2 \
209209
--pipework-version 9ba97f1735022fb5f811d9c2a304dda33fae1ad1 \
210210
--sockperf-version 19accb5229503dac7833f03713b978cb7fc48762 \

5G_Core_Network/Additional_Cores_5GDeploy/generate_configurations.sh

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,12 @@ if [ ! -f "options.yaml" ]; then
123123
echo "plmn: 00101" >>"options.yaml"
124124
echo "tac: 7" >>"options.yaml"
125125
echo "" >>"options.yaml"
126-
echo "# Configure the DNN/APN" >>"options.yaml"
127-
echo "dnn: nist-dnn" >>"options.yaml"
128-
echo "" >>"options.yaml"
129126
echo "# Configure the Single Network Slice Selection Assistance Information (S-NSSAI)" >>"options.yaml"
130127
echo "# NOTE: \"sst\" and \"sd\" are interpreted as hexadecimal values (no 0x prefix)." >>"options.yaml"
131128
echo "slices:" >>"options.yaml"
132129
echo " - sst: 1" >>"options.yaml"
133130
echo " sd: FFFFFF" >>"options.yaml"
131+
echo " dnn: nist-dnn" >>"options.yaml"
134132
echo "" >>"options.yaml"
135133
echo "# If false, AMF will use a local IP, otherwise it will use the hostname IP" >>"options.yaml"
136134
echo "expose_amf_over_hostname: false" >>"options.yaml"
@@ -193,10 +191,10 @@ if [ "$CORE_TO_USE" == "open5gs" ]; then
193191
fi
194192

195193
# Configure the DNN, SST, and SD values
196-
DNN=$(sed -n 's/^dnn: //p' options.yaml)
194+
CURRENT_DNN=$(yq eval '.slices[0].dnn' options.yaml)
197195
SST=$(yq eval '.slices[0].sst' options.yaml)
198196
SD=$(yq eval '.slices[0].sd' options.yaml)
199-
if [[ -z "$DNN" || "$DNN" == "null" ]]; then
197+
if [[ -z "$CURRENT_DNN" || "$CURRENT_DNN" == "null" ]]; then
200198
echo "DNN is not set in options.yaml, please ensure that \"dnn\" is set."
201199
exit 1
202200
fi
@@ -241,7 +239,7 @@ for UE_NUMBER in "${UE_NUMBERS[@]}"; do
241239
echo "Registering UE $UE_NUMBER..."
242240
# Fetch the UE's OPc, IMEI, IMSI, KEY, and NAMESPACE
243241
read -r UE_OPC UE_IMEI UE_IMSI UE_KEY UE_NAMESPACE < <("$UE_CREDENTIAL_GENERATOR_SCRIPT" "$UE_NUMBER" "$PLMN")
244-
./install_scripts/register_subscriber.sh --imsi "$UE_IMSI" --key "$UE_KEY" --opc "$UE_OPC" --apn "$DNN"
242+
./install_scripts/register_subscriber.sh --imsi "$UE_IMSI" --key "$UE_KEY" --opc "$UE_OPC" --apn "$CURRENT_DNN"
245243
done
246244

247245
# Ensure that the core is set correctly
@@ -425,15 +423,15 @@ echo "$UPF_TO_USE" >>core_upf_used.txt
425423
# Revise configuration file netdef.json
426424
if [ -f "netdef.json" ]; then
427425
echo "Setting subscribers field in netdef.json..."
428-
sed -i "s/\"internet\"/\"$DNN\"/g" netdef.json
429-
sed -i "s/'internet'/'$DNN'/g" netdef.json
426+
sed -i "s/\"internet\"/\"$CURRENT_DNN\"/g" netdef.json
427+
sed -i "s/'internet'/'$CURRENT_DNN'/g" netdef.json
430428
fi
431429

432430
# Revise configuration files in the cp-cfg directory
433431
for CPFILE in cp-cfg/*; do
434432
if [ -f "$CPFILE" ]; then
435-
sed -i "s/\"internet\"/\"$DNN\"/g" "$CPFILE"
436-
sed -i "s/'internet'/'$DNN'/g" "$CPFILE"
433+
sed -i "s/\"internet\"/\"$CURRENT_DNN\"/g" "$CPFILE"
434+
sed -i "s/'internet'/'$CURRENT_DNN'/g" "$CPFILE"
437435
fi
438436
done
439437

@@ -450,21 +448,21 @@ for FILE in up-cfg/upf1.yaml up-cfg/upf140.yaml up-cfg/upf141.yaml; do
450448
)
451449
' "$FILE" >tmp.yaml && mv tmp.yaml "$FILE"
452450

453-
sed -i "s/\"internet\"/\"$DNN\"/g" "$FILE"
454-
sed -i "s/'internet'/'$DNN'/g" "$FILE"
451+
sed -i "s/\"internet\"/\"$CURRENT_DNN\"/g" "$FILE"
452+
sed -i "s/'internet'/'$CURRENT_DNN'/g" "$FILE"
455453
fi
456454
done
457455

458456
# Revise compose.yml
459457
if [ -f "compose.yml" ]; then
460-
# Replace "dnn":["internet"] with dnn:["$DNN"]
461-
sed -i -E 's/"dnn"[[:space:]]*:[[:space:]]*\[[[:space:]]*"internet"[[:space:]]*\]/"dnn":["'"$DNN"'"]/g' compose.yml
462-
# Replace "dnn":"internet" with "dnn":"$DNN"
463-
sed -i -E 's/"dnn"[[:space:]]*:[[:space:]]*"internet"/"dnn":"'"$DNN"'"/g' compose.yml
464-
# Replace ${SST_PADDED}${SD_HEX}_internet with ${SST_PADDED}${SD_HEX}_${DNN}
465-
sed -i -E "s/${SST_PADDED}${SD_HEX}_internet/${SST_PADDED}${SD_HEX}_${DNN}/g" compose.yml
466-
# Replace ${SST_PADDED}${SD_HEX}:internet with ${SST_PADDED}${SD_HEX}:${DNN}
467-
sed -i -E "s/${SST_PADDED}${SD_HEX}:internet/${SST_PADDED}${SD_HEX}:${DNN}/g" compose.yml
458+
# Replace "dnn":["internet"] with dnn:["$CURRENT_DNN"]
459+
sed -i -E 's/"dnn"[[:space:]]*:[[:space:]]*\[[[:space:]]*"internet"[[:space:]]*\]/"dnn":["'"$CURRENT_DNN"'"]/g' compose.yml
460+
# Replace "dnn":"internet" with "dnn":"$CURRENT_DNN"
461+
sed -i -E 's/"dnn"[[:space:]]*:[[:space:]]*"internet"/"dnn":"'"$CURRENT_DNN"'"/g' compose.yml
462+
# Replace ${SST_PADDED}${SD_HEX}_internet with ${SST_PADDED}${SD_HEX}_${CURRENT_DNN}
463+
sed -i -E "s/${SST_PADDED}${SD_HEX}_internet/${SST_PADDED}${SD_HEX}_${CURRENT_DNN}/g" compose.yml
464+
# Replace ${SST_PADDED}${SD_HEX}:internet with ${SST_PADDED}${SD_HEX}:${CURRENT_DNN}
465+
sed -i -E "s/${SST_PADDED}${SD_HEX}:internet/${SST_PADDED}${SD_HEX}:${CURRENT_DNN}/g" compose.yml
468466
fi
469467

470468
# Revise cp-sql/oai_db.sql
@@ -477,19 +475,19 @@ fi
477475

478476
# Revise cp-sql/smf.sql
479477
if [ -f "cp-sql/smf.sql" ]; then
480-
# Replace "'internet'" with "'$DNN'"
481-
sed -i "s/'internet'/'$DNN'/g" cp-sql/smf.sql
478+
# Replace "'internet'" with "'$CURRENT_DNN'"
479+
sed -i "s/'internet'/'$CURRENT_DNN'/g" cp-sql/smf.sql
482480
fi
483481

484482
# Revise cp-sql/udm.sql
485483
if [ -f "cp-sql/udm.sql" ]; then
486-
# Replace "'internet'" with "'$DNN'"
487-
sed -i "s/'internet'/'$DNN'/g" cp-sql/udm.sql
484+
# Replace "'internet'" with "'$CURRENT_DNN'"
485+
sed -i "s/'internet'/'$CURRENT_DNN'/g" cp-sql/udm.sql
488486
fi
489487

490488
if [ -f "cp-db/open5gs.sh" ]; then
491-
# Replace " internet " with " $DNN "
492-
sed -i "s/ internet / $DNN /g" cp-db/open5gs.sh
489+
# Replace " internet " with " $CURRENT_DNN "
490+
sed -i "s/ internet / $CURRENT_DNN /g" cp-db/open5gs.sh
493491
fi
494492

495493
### End of post-generation patching ###

5G_Core_Network/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ The 5G Core Network operates as a standalone network based on the 3GPP specifica
88
- **Generate Configurations**: Use `./generate_configurations.sh` to create configuration files.
99
- Configuration files can be accessed and modified in the `configs` directory.
1010
- **Start the 5G Core Network**: Use `./run.sh` to start the 5G Core components.
11-
- To start each component in its own gnome-terminal instance, use `./run.sh show`.
11+
- To start each component in its own terminal instance, use `./run.sh show`.
1212
- **Stop the Network**: Terminate the network operation with `./stop.sh`.
1313
- **Status**: Check if the 5G Core is running with `./is_running.sh`. The output will display which components are running.
1414
- **Logs**: Access logs by navigating to the `logs` directory.

5G_Core_Network/full_install.sh

Lines changed: 44 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
# Exit immediately if a command fails
3232
set -e
3333

34+
CLEAN_INSTALL=false
35+
3436
APTVARS="NEEDRESTART_MODE=l NEEDRESTART_SUSPEND=1 DEBIAN_FRONTEND=noninteractive"
3537
if ! command -v realpath &>/dev/null; then
3638
echo "Package \"coreutils\" not found, installing..."
@@ -74,14 +76,12 @@ if [ ! -f "options.yaml" ]; then
7476
echo "plmn: 00101" >>"options.yaml"
7577
echo "tac: 7" >>"options.yaml"
7678
echo "" >>"options.yaml"
77-
echo "# Configure the DNN/APN" >>"options.yaml"
78-
echo "dnn: nist-dnn" >>"options.yaml"
79-
echo "" >>"options.yaml"
8079
echo "# Configure the Single Network Slice Selection Assistance Information (S-NSSAI)" >>"options.yaml"
8180
echo "# NOTE: \"sst\" and \"sd\" are interpreted as hexadecimal values (no 0x prefix)." >>"options.yaml"
8281
echo "slices:" >>"options.yaml"
8382
echo " - sst: 1" >>"options.yaml"
8483
echo " sd: FFFFFF" >>"options.yaml"
84+
echo " dnn: nist-dnn" >>"options.yaml"
8585
echo "" >>"options.yaml"
8686
echo "# If false, AMF will use a local IP, otherwise it will use the hostname IP" >>"options.yaml"
8787
echo "expose_amf_over_hostname: false" >>"options.yaml"
@@ -134,17 +134,27 @@ fi
134134
MONGO_HEALTHY=true
135135
if command -v mongod &>/dev/null; then
136136
./install_scripts/start_mongodb.sh
137-
if ! mongo --host 127.0.0.1 --port 27017 --quiet --eval 'db.adminCommand({ping:1}).ok' admin &>/dev/null; then
137+
if command -v mongosh &>/dev/null; then
138+
if ! mongosh --host 127.0.0.1 --port 27017 --quiet --eval 'quit(db.adminCommand({ ping: 1 }).ok ? 0 : 1)' admin &>/dev/null; then
139+
MONGO_HEALTHY=false
140+
echo "MongoDB is not responding to mongosh ping."
141+
fi
142+
elif command -v mongo &>/dev/null; then
143+
if ! mongo --host 127.0.0.1 --port 27017 --quiet --eval 'quit(db.adminCommand({ ping: 1 }).ok ? 0 : 1)' admin &>/dev/null; then
144+
MONGO_HEALTHY=false
145+
echo "MongoDB is not responding to mongo shell ping."
146+
fi
147+
else
138148
MONGO_HEALTHY=false
139-
echo "MongoDB is not responding to ping."
149+
echo "Unable to ensure MongoDB is healthy"
140150
fi
141151
else
142152
MONGO_HEALTHY=false
143153
echo "MongoDB not found."
144154
fi
145155

146156
# Check for open5gs-amfd and open5gs-upfd binaries to determine if Open5GS is already installed
147-
if [ -f "open5gs/install/bin/open5gs-amfd" ] && [ -f "open5gs/install/bin/open5gs-upfd" ] && [ "$MONGO_HEALTHY" = true ]; then
157+
if [ "$CLEAN_INSTALL" = false ] && [ -f "open5gs/install/bin/open5gs-amfd" ] && [ -f "open5gs/install/bin/open5gs-upfd" ] && [ "$MONGO_HEALTHY" = true ]; then
148158
echo "Open5GS is already installed, skipping."
149159
exit 0
150160
fi
@@ -176,6 +186,11 @@ fi
176186
if [ ! -d "open5gs" ]; then
177187
echo "Cloning Open5GS..."
178188
./install_scripts/git_clone.sh https://github.com/open5gs/open5gs.git
189+
190+
# Patch mongoc_collection_count removal in MongoDB 2.0+ (Ubuntu 26.04)
191+
sed -i 's/mongoc_collection_count(/mongoc_collection_count_documents(/g' open5gs/tests/common/context.c
192+
sed -i 's/mongoc_collection_count (/mongoc_collection_count_documents (/g' open5gs/tests/common/context.c
193+
sed -i 's/collection, MONGOC_QUERY_NONE, key, 0, 0, NULL, &error/collection, key, NULL, NULL, NULL, \&error/g' open5gs/tests/common/context.c
179194
fi
180195

181196
cd "$SCRIPT_DIR/open5gs"
@@ -214,11 +229,32 @@ sudo usermod -a -G open5gs open5gs
214229

215230
echo "Installing dependencies for building Open5GS..."
216231

232+
export CFLAGS="-Wno-error=incompatible-pointer-types"
233+
export CXXFLAGS="-Wno-error=incompatible-pointer-types"
234+
217235
# Code from (https://open5gs.org/open5gs/docs/guide/02-building-open5gs-from-sources#building-open5gs):
218236
sudo env $APTVARS apt-get install -y python3-pip python3-setuptools python3-wheel python3-venv ninja-build build-essential flex bison git cmake libsctp-dev libgnutls28-dev libgcrypt-dev libssl-dev libmongoc-dev libbson-dev libyaml-dev libmicrohttpd-dev libcurl4-gnutls-dev libnghttp2-dev libtins-dev libtalloc-dev
219237
python3 -m venv .venv
220238
source .venv/bin/activate
221-
pip install --upgrade meson # Ensure pip version overrides apt version to prevent segmentation faults
239+
python3 -m pip install --upgrade meson # Ensure pip version overrides apt version to prevent segmentation faults
240+
241+
# Create a pkg-config compatibility shim mapping libmongoc-1.0 to mongoc2
242+
if ! pkg-config --exists libmongoc-1.0 && pkg-config --exists mongoc2; then
243+
COMPAT_PKGCONFIG_DIR="$(pwd)/.pkgconfig"
244+
mkdir -p "$COMPAT_PKGCONFIG_DIR"
245+
MONGOC2_INCLUDES=$(pkg-config --cflags-only-I mongoc2 | grep -o '\-I[^ ]*mongoc[^ ]*')
246+
cat >"$COMPAT_PKGCONFIG_DIR/libmongoc-1.0.pc" <<EOF
247+
Name: libmongoc-1.0
248+
Description: Compatibility shim mapping libmongoc-1.0 to mongoc2
249+
Version: 2
250+
Requires: mongoc2
251+
Libs:
252+
Cflags: ${MONGOC2_INCLUDES}/mongoc
253+
EOF
254+
export PKG_CONFIG_PATH="$COMPAT_PKGCONFIG_DIR:${PKG_CONFIG_PATH}"
255+
echo "Created pkg-config compatibility shim mapping libmongoc-1.0 to mongoc2"
256+
fi
257+
222258
if apt-cache show libidn-dev >/dev/null 2>&1; then
223259
sudo env $APTVARS apt-get install -y --no-install-recommends libidn-dev
224260
else
@@ -230,7 +266,7 @@ rm -rf build
230266
# Check if Open5GS has already been built and installed
231267
if [ ! -d "build" ]; then
232268
echo "Compiling Open5GS with Meson..."
233-
meson build --prefix="$(pwd)/install" -Dc_args="-fPIC" -Dcpp_args="-fPIC" -Dc_link_args="-fPIC" -Dcpp_link_args="-fPIC"
269+
meson setup build --prefix="$(pwd)/install" -Dc_args="-fPIC" -Dcpp_args="-fPIC" -Dc_link_args="-fPIC" -Dcpp_link_args="-fPIC"
234270
else
235271
echo "Open5GS build directory already exists."
236272
fi

5G_Core_Network/generate_configurations.sh

Lines changed: 15 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,12 @@ if [ ! -f "options.yaml" ]; then
9393
echo "plmn: 00101" >>"options.yaml"
9494
echo "tac: 7" >>"options.yaml"
9595
echo "" >>"options.yaml"
96-
echo "# Configure the DNN/APN" >>"options.yaml"
97-
echo "dnn: nist-dnn" >>"options.yaml"
98-
echo "" >>"options.yaml"
9996
echo "# Configure the Single Network Slice Selection Assistance Information (S-NSSAI)" >>"options.yaml"
10097
echo "# NOTE: \"sst\" and \"sd\" are interpreted as hexadecimal values (no 0x prefix)." >>"options.yaml"
10198
echo "slices:" >>"options.yaml"
10299
echo " - sst: 1" >>"options.yaml"
103100
echo " sd: FFFFFF" >>"options.yaml"
101+
echo " dnn: nist-dnn" >>"options.yaml"
104102
echo "" >>"options.yaml"
105103
echo "# If false, AMF will use a local IP, otherwise it will use the hostname IP" >>"options.yaml"
106104
echo "expose_amf_over_hostname: false" >>"options.yaml"
@@ -152,10 +150,10 @@ echo "MNC (Mobile Network Code): $MNC"
152150
echo "TAC value: $TAC"
153151

154152
# Configure the DNN, SST, and SD values
155-
DNN=$(sed -n 's/^dnn: //p' options.yaml)
153+
DNN=($(yq eval '.slices[].dnn' options.yaml))
156154
SST=($(yq eval '.slices[].sst' options.yaml))
157155
SD=($(yq eval '.slices[].sd' options.yaml))
158-
if [[ -z "$DNN" || "$DNN" == "null" ]]; then
156+
if [[ -z "${DNN[0]}" || "${DNN[0]}" == "null" ]]; then
159157
echo "DNN is not set in options.yaml, please ensure that \"dnn\" is set."
160158
exit 1
161159
fi
@@ -166,6 +164,7 @@ fi
166164

167165
# SST/SD are configured in options.yaml as hex without 0x prefix.
168166
for i in "${!SST[@]}"; do
167+
CURRENT_DNN="${DNN[$i]}"
169168
CURRENT_SST="${SST[$i]}"
170169
CURRENT_SD="${SD[$i]}"
171170

@@ -379,6 +378,7 @@ set_snssai() {
379378
local NSI_URI=$(yq eval '.nssf.sbi.client.nsi[0].uri' "$NSSF_FILE_PATH")
380379

381380
for i in "${!SST[@]}"; do
381+
local CURRENT_DNN="${DNN[$i]}"
382382
local CURRENT_SST="${SST[$i]}"
383383
local CURRENT_SD="${SD[$i]}"
384384

@@ -398,7 +398,7 @@ set_snssai() {
398398
fi
399399
yq -i ".smf.info[0].s_nssai[$i].sst = $CURRENT_SST" "$SMF_FILE_PATH"
400400
yq -i ".smf.info[0].s_nssai[$i].sd = \"$CURRENT_SD\"" "$SMF_FILE_PATH"
401-
yq -i ".smf.info[0].s_nssai[$i].dnn = [\"$DNN\"]" "$SMF_FILE_PATH"
401+
yq -i ".smf.info[0].s_nssai[$i].dnn = [\"$CURRENT_DNN\"]" "$SMF_FILE_PATH"
402402
done
403403
}
404404

@@ -496,31 +496,18 @@ for UE_NUMBER in "${UE_NUMBERS[@]}"; do
496496
# Fetch the UE's OPc, IMEI, IMSI, KEY, and NAMESPACE
497497
read -r UE_OPC UE_IMEI UE_IMSI UE_KEY UE_NAMESPACE < <("$UE_CREDENTIAL_GENERATOR_SCRIPT" "$UE_NUMBER" "$PLMN")
498498

499-
# Register with the first slice
500-
./install_scripts/register_subscriber.sh --imsi "$UE_IMSI" --key "$UE_KEY" --opc "$UE_OPC" --apn "$DNN" --sst "${SST[0]}" --sd "${SD[0]}" $IPV4_LINE
501-
502-
# Iterate from the second slice
503-
for ((i = 1; i < ${#SST[@]}; i++)); do
504-
CURRENT_SST="${SST[$i]}"
505-
CURRENT_SD="${SD[$i]}"
506-
507-
echo "Adding slice $i (SST: $CURRENT_SST, SD: $CURRENT_SD) to UE $UE_NUMBER..."
508-
./open5gs/misc/db/open5gs-dbctl update_slice "$UE_IMSI" "$DNN" "$CURRENT_SST" "$CURRENT_SD"
509-
510-
# Apply Static IP for the secondary slices
499+
# Build the array of slices for subscriber
500+
SLICES_ARGS=()
501+
for ((i = 0; i < ${#SST[@]}; i++)); do
502+
SLICES_ARGS+=(--apn "$CURRENT_DNN" --sst "${SST[$i]}" --sd "${SD[$i]}")
503+
# Apply static IP if UE_IPV4 was found earlier
511504
if [ -n "$UE_IPV4" ]; then
512-
mongosh open5gs --eval "
513-
db.subscribers.updateOne(
514-
{ \"imsi\": \"$UE_IMSI\", \"slice.sd\": \"$CURRENT_SD\" },
515-
{
516-
\$set: {
517-
\"slice.$i.session.0.ue\": { \"ipv4\": \"$UE_IPV4\" },
518-
\"slice.$i.session.0.type\": 1
519-
}
520-
}
521-
)"
505+
SLICES_ARGS+=(--ipv4 "$UE_IPV4")
522506
fi
523507
done
508+
509+
# Register the subscriber
510+
./install_scripts/register_subscriber.sh --imsi "$UE_IMSI" --key "$UE_KEY" --opc "$UE_OPC" "${SLICES_ARGS[@]}"
524511
done
525512

526513
# Restart Open5GS services to apply changes

0 commit comments

Comments
 (0)