Skip to content

Commit 362abd7

Browse files
committed
Tag v1.4.5
1 parent 6a406cf commit 362abd7

231 files changed

Lines changed: 1264 additions & 665 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/README.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,16 @@ By default, the configuration process automatically unregisters all subscribers,
7373
<td>...2</td>
7474
</tr>
7575
<tr>
76-
<td>netns</td>
77-
<td>ue1</td>
78-
<td>ue2</td>
79-
<td>ue3</td>
76+
<td>Address</td>
77+
<td>10.45.0.101</td>
78+
<td>...102</td>
79+
<td>...103</td>
80+
</tr>
81+
<tr>
82+
<td>Namespace</td>
83+
<td>ue1</td>
84+
<td>ue2</td>
85+
<td>ue3</td>
8086
</tr>
8187
<!-- <tr>
8288
<td>TX Port</td>

5G_Core_Network/full_install.sh

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,14 @@ set -e
3434
APTVARS="NEEDRESTART_MODE=l NEEDRESTART_SUSPEND=1 DEBIAN_FRONTEND=noninteractive"
3535
if ! command -v realpath &>/dev/null; then
3636
echo "Package \"coreutils\" not found, installing..."
37-
sudo $APTVARS apt-get install -y coreutils
37+
sudo env $APTVARS apt-get install -y coreutils
3838
fi
3939

4040
SCRIPT_DIR=$(dirname "$(realpath "$0")")
4141
cd "$SCRIPT_DIR"
4242

43-
# Check if the YAML editor is installed, and install it if not
44-
if ! command -v yq &>/dev/null; then
45-
sudo "$SCRIPT_DIR/install_scripts/./install_yq.sh"
46-
fi
47-
# Check that the correct version of yq is installed
48-
if ! yq --version 2>/dev/null | grep -q 'https://github\.com/mikefarah/yq'; then
49-
echo "ERROR: Detected an incompatible yq installation."
50-
echo "Please ensure the Python yq is uninstalled with \"pip uninstall -y yq\", then re-run this script."
51-
exit 1
52-
fi
43+
# Ensure the correct YAML editor is installed
44+
sudo "$SCRIPT_DIR/install_scripts/./ensure_consistent_yq.sh"
5345

5446
echo "Parsing options.yaml..."
5547
# Check if the YAML file exists, if not, set and save default values
@@ -93,7 +85,7 @@ if [[ "$USE_SYSTEMCTL" == "null" || -z "$USE_SYSTEMCTL" ]]; then
9385
fi
9486

9587
# Check for open5gs-amfd and open5gs-upfd binaries to determine if Open5GS is already installed
96-
if [ -f "open5gs/install/bin/open5gs-amfd" ] && [ -f "open5gs/install/bin/open5gs-upfd" ]; then
88+
if [ -f "open5gs/install/bin/open5gs-amfd" ] && [ -f "open5gs/install/bin/open5gs-upfd" ] && command -v mongod &>/dev/null; then
9789
echo "Open5GS is already installed, skipping."
9890
exit 0
9991
fi
@@ -159,11 +151,11 @@ sudo usermod -a -G open5gs open5gs
159151
echo "Installing dependencies for building Open5GS..."
160152

161153
# Code from (https://open5gs.org/open5gs/docs/guide/02-building-open5gs-from-sources#building-open5gs):
162-
sudo $APTVARS apt-get install -y python3-pip python3-setuptools python3-wheel 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 meson
154+
sudo env $APTVARS apt-get install -y python3-pip python3-setuptools python3-wheel 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 meson
163155
if apt-cache show libidn-dev >/dev/null 2>&1; then
164-
sudo $APTVARS apt-get install -y --no-install-recommends libidn-dev
156+
sudo env $APTVARS apt-get install -y --no-install-recommends libidn-dev
165157
else
166-
sudo $APTVARS apt-get install -y --no-install-recommends libidn11-dev
158+
sudo env $APTVARS apt-get install -y --no-install-recommends libidn11-dev
167159
fi
168160

169161
rm -rf build

5G_Core_Network/full_uninstall.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@
3131
# Do not exit immediately if a command fails
3232
set +e
3333

34-
echo "# Script: $(realpath $0)..."
34+
echo "# Script: $(realpath "$0")..."
3535

3636
APTVARS="NEEDRESTART_MODE=l NEEDRESTART_SUSPEND=1 DEBIAN_FRONTEND=noninteractive"
3737
if ! command -v realpath &>/dev/null; then
3838
echo "Package \"coreutils\" not found, installing..."
39-
sudo $APTVARS apt-get install -y coreutils
39+
sudo env $APTVARS apt-get install -y coreutils
4040
fi
4141

4242
SCRIPT_DIR=$(dirname "$(realpath "$0")")
@@ -85,5 +85,5 @@ sudo rm -rf install_time.txt
8585
echo
8686
echo
8787
echo "################################################################################"
88-
echo "# Successfully uninstalled 5G Core #"
88+
echo "# Successfully uninstalled Open5GS #"
8989
echo "################################################################################"

5G_Core_Network/generate_configurations.sh

Lines changed: 25 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -36,22 +36,14 @@ UE_NUMBERS=(3 2 1) # Subscribers from UE 3 to UE 1
3636
APTVARS="NEEDRESTART_MODE=l NEEDRESTART_SUSPEND=1 DEBIAN_FRONTEND=noninteractive"
3737
if ! command -v realpath &>/dev/null; then
3838
echo "Package \"coreutils\" not found, installing..."
39-
sudo $APTVARS apt-get install -y coreutils
39+
sudo env $APTVARS apt-get install -y coreutils
4040
fi
4141

4242
SCRIPT_DIR=$(dirname "$(realpath "$0")")
4343
cd "$SCRIPT_DIR"
4444

45-
# Check if the YAML editor is installed, and install it if not
46-
if ! command -v yq &>/dev/null; then
47-
sudo "$SCRIPT_DIR/install_scripts/./install_yq.sh"
48-
fi
49-
# Check that the correct version of yq is installed
50-
if ! yq --version 2>/dev/null | grep -q 'https://github\.com/mikefarah/yq'; then
51-
echo "ERROR: Detected an incompatible yq installation."
52-
echo "Please ensure the Python yq is uninstalled with \"pip uninstall -y yq\", then re-run this script."
53-
exit 1
54-
fi
45+
# Ensure the correct YAML editor is installed
46+
sudo "$SCRIPT_DIR/install_scripts/./ensure_consistent_yq.sh"
5547

5648
echo "Parsing options.yaml..."
5749
# Check if the YAML file exists, if not, set and save default values
@@ -350,39 +342,22 @@ if [[ "$OGSTUN_IPV6" == "null" || -z "$OGSTUN_IPV6" ]]; then
350342
exit 1
351343
fi
352344

353-
# Extract the first IPv4 address from a CIDR block by replacing the last octet with '.1'
354-
# For example, 10.45.0.0/16 --> 10.45.0.1/16
355-
grab_first_ipv4_address() {
356-
local IP=$1
357-
echo ${IP%.*}.1/${IP#*/}
358-
}
359-
360-
# Extract the first IPv6 address from a CIDR block by replacing the suffix with '::1'.
361-
# For example, 2001:db8:cafe::/48 --> 2001:db8:cafe::1/48
362-
grab_first_ipv6_address() {
363-
local IP=$1
364-
echo ${IP%::*}::1/${IP#*/}
365-
}
366-
367-
# Remove the CIDR suffix from an IP address
368-
# For example, 10.45.0.1/16 --> 10.45.0.1
369-
remove_cidr_suffix() {
370-
local IP=$1
371-
echo ${IP%/*}
372-
}
345+
if ! command -v python3 &>/dev/null; then
346+
echo "Python is not installed. Installing Python..."
347+
sudo apt-get update
348+
sudo apt-get install -y python3
349+
fi
373350

374351
# Extract the first IPv4 and IPv6 addresses from the CIDR blocks
375-
OGSTUN_IPV4_1=$(grab_first_ipv4_address "$OGSTUN_IPV4")
376-
OGSTUN_IPV6_1=$(grab_first_ipv6_address "$OGSTUN_IPV6")
377-
OGSTUN_IPV4_1_NO_CIDR=$(remove_cidr_suffix "$OGSTUN_IPV4_1")
378-
OGSTUN_IPV6_1_NO_CIDR=$(remove_cidr_suffix "$OGSTUN_IPV6_1")
352+
OGSTUN_IPV4_1="$(python3 install_scripts/fetch_nth_ip.py "$OGSTUN_IPV4" 0)"
353+
OGSTUN_IPV6_1="$(python3 install_scripts/fetch_nth_ip.py "$OGSTUN_IPV6" 0)"
379354

380355
if [ "$EXPOSE_AMF_OVER_HOSTNAME" = true ]; then
381356
AMF_IP=$(hostname -I | awk '{print $1}')
382357
set_configuration_server_ips $AMF_IP
383358
# Need an address for the gNodeB to bind to that is not the host IP.
384359
if [ "$IS_OPEN5GS_ON_HOST" = true ]; then
385-
AMF_IP_BIND=$OGSTUN_IPV4_1_NO_CIDR
360+
AMF_IP_BIND=$OGSTUN_IPV4_1
386361
else
387362
AMF_IP_BIND=$AMF_IP
388363
fi
@@ -391,7 +366,7 @@ else
391366
AMF_IP_BIND="127.0.0.1"
392367
fi
393368

394-
set_configuration_session_gateways $OGSTUN_IPV4 $OGSTUN_IPV4_1_NO_CIDR $OGSTUN_IPV6 $OGSTUN_IPV6_1_NO_CIDR
369+
set_configuration_session_gateways $OGSTUN_IPV4 $OGSTUN_IPV4_1 $OGSTUN_IPV6 $OGSTUN_IPV6_1
395370

396371
# Configure the Single Network Slice Selection Assistance Information (S-NSSAI)
397372
set_snssai "$SST" "$SD"
@@ -413,6 +388,9 @@ configure_plmn_tac $MCC $MNC $TAC
413388

414389
sudo ./install_scripts/network_config.sh
415390

391+
# Enable SCTP kernel module
392+
sudo ./install_scripts/enable_sctp.sh
393+
416394
# Enable IPv4/IPv6 Forwarding
417395
sudo sysctl -w net.ipv4.ip_forward=1
418396
sudo sysctl -w net.ipv6.conf.all.forwarding=1
@@ -433,11 +411,20 @@ echo "Unregistering all subscribers in Open5GS database..."
433411

434412
# Register the subscribers
435413
for UE_NUMBER in "${UE_NUMBERS[@]}"; do
414+
UE_INDEX=$((UE_NUMBER + 99))
415+
UE_IPV4=$(python3 install_scripts/fetch_nth_ip.py "$OGSTUN_IPV4" "$UE_INDEX")
416+
if [ $? -eq 0 ]; then
417+
IPV4_LINE="--ipv4 $UE_IPV4"
418+
else
419+
IPV4_LINE=""
420+
fi
421+
436422
echo
437423
echo "Registering UE $UE_NUMBER..."
424+
438425
# Fetch the UE's OPc, IMEI, IMSI, KEY, and NAMESPACE
439426
read -r UE_OPC UE_IMEI UE_IMSI UE_KEY UE_NAMESPACE < <("$UE_CREDENTIAL_GENERATOR_SCRIPT" "$UE_NUMBER" "$PLMN")
440-
./install_scripts/register_subscriber.sh --imsi "$UE_IMSI" --key "$UE_KEY" --opc "$UE_OPC" --apn "$DNN" --sst "$SST" --sd "$SD"
427+
./install_scripts/register_subscriber.sh --imsi "$UE_IMSI" --key "$UE_KEY" --opc "$UE_OPC" --apn "$DNN" --sst "$SST" --sd "$SD" $IPV4_LINE
441428
done
442429

443430
# Restart Open5GS services to apply changes

5G_Core_Network/install_scripts/disable_firewall.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
# damage to property. The software developed by NIST employees is not subject to
2929
# copyright protection within the United States.
3030

31-
echo "# Script: $(realpath $0)..."
31+
echo "# Script: $(realpath "$0")..."
3232

3333
ATTEMPTS=0
3434
MAX_ATTEMPTS=10

User_Equipment/install_scripts/install_yq.sh renamed to 5G_Core_Network/install_scripts/enable_sctp.sh

Lines changed: 36 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -28,76 +28,47 @@
2828
# damage to property. The software developed by NIST employees is not subject to
2929
# copyright protection within the United States.
3030

31-
echo "# Script: $(realpath $0)..."
31+
echo "# Script: $(realpath "$0")..."
3232

33-
# Uninstall yq with: sudo rm -rf /usr/local/bin/yq; hash -r
34-
if command -v yq &>/dev/null; then
35-
echo "Already installed yq, skipping."
36-
exit 0
37-
fi
33+
# Exit immediately if a command fails
34+
set -e
3835

39-
echo "Installing yq..."
36+
APTVARS="NEEDRESTART_MODE=l NEEDRESTART_SUSPEND=1 DEBIAN_FRONTEND=noninteractive"
37+
if ! dpkg -s lksctp-tools >/dev/null 2>&1; then
38+
sudo apt-get update
39+
sudo env $APTVARS apt-get install -y lksctp-tools
40+
fi
41+
if ! dpkg -s libsctp1 >/dev/null 2>&1; then
42+
sudo apt-get update
43+
sudo env $APTVARS apt-get install -y libsctp1
44+
fi
45+
if ! dpkg -s libsctp-dev >/dev/null 2>&1; then
46+
sudo apt-get update
47+
sudo env $APTVARS apt-get install -y libsctp-dev
48+
fi
4049

41-
# Determine the processor architecture
42-
ARCH_SUFFIX=""
43-
case $(uname -m) in
44-
"x86_64")
45-
ARCH_SUFFIX="linux_amd64"
46-
;;
47-
"aarch64")
48-
ARCH_SUFFIX="linux_arm64"
49-
;;
50-
"armv7l" | "armv6l")
51-
ARCH_SUFFIX="linux_arm"
52-
;;
53-
"i386" | "i686")
54-
ARCH_SUFFIX="linux_386"
55-
;;
56-
"ppc64le")
57-
ARCH_SUFFIX="linux_ppc64le"
58-
;;
59-
"s390x")
60-
ARCH_SUFFIX="linux_s390x"
61-
;;
62-
"mips")
63-
ARCH_SUFFIX="linux_mips"
64-
;;
65-
"mips64")
66-
ARCH_SUFFIX="linux_mips64"
67-
;;
68-
"mips64el" | "mips64le")
69-
ARCH_SUFFIX="linux_mips64le"
70-
;;
71-
"mipsel" | "mipsle")
72-
ARCH_SUFFIX="linux_mipsle"
73-
;;
74-
*)
75-
echo "Unsupported architecture for yq: $(uname -m)"
76-
exit 1
77-
;;
78-
esac
50+
# Load necessary kernel modules
51+
sudo modprobe overlay || true
52+
sudo modprobe br_netfilter || true
7953

80-
YQ_URL="https://github.com/mikefarah/yq/releases/latest/download/yq_${ARCH_SUFFIX}.tar.gz"
54+
# Load SCTP module
55+
sudo modprobe sctp
8156

82-
# Create a temporary directory for the download
83-
TEMP_DIR=$(mktemp -d)
84-
TEMP_PATH="$TEMP_DIR/yq.tar.gz"
57+
# Get the kernel major version
58+
KERNEL_VERSION="$(uname -r | cut -d'-' -f1)"
59+
MAJOR_VERSION="$(echo "$KERNEL_VERSION" | cut -d'.' -f1)"
8560

86-
echo "Downloading yq from $YQ_URL..."
87-
HTTP_STATUS=$(curl -L -w "%{http_code}" -o "$TEMP_PATH" "$YQ_URL")
88-
if [ "$HTTP_STATUS" -eq 200 ]; then
89-
echo "Extracting yq..."
90-
tar -xzf "$TEMP_PATH" -C "$TEMP_DIR"
91-
if [ -f "$TEMP_DIR/./yq_$ARCH_SUFFIX" ]; then
92-
sudo mv "$TEMP_DIR/./yq_$ARCH_SUFFIX" /usr/local/bin/yq
93-
sudo chmod +x /usr/local/bin/yq
94-
echo "Successfully installed yq."
95-
else
96-
echo "Failed to extract yq from the tar.gz."
97-
exit 1
98-
fi
61+
# Conditional loading of connection tracking modules based on kernel version
62+
if [ "$MAJOR_VERSION" -lt 5 ]; then
63+
# For older kernels (before version 5), load IPv4 and IPv6 specific modules
64+
sudo modprobe nf_conntrack_ipv4 || true
65+
sudo modprobe nf_conntrack_ipv6 || true
66+
sudo modprobe nf_conntrack_proto_sctp || true
9967
else
100-
sudo rm -rf "$TEMP_DIR"
101-
echo "Failed to download yq for the architecture: ${ARCH_SUFFIX}, HTTP status was $HTTP_STATUS."
102-
exit 1
68+
# For newer kernels (version 5 and later), use the unified nf_conntrack module
69+
sudo modprobe nf_conntrack || true
70+
sudo modprobe nf_conntrack_sctp || true
10371
fi
72+
73+
echo "SCTP kernel module present:"
74+
lsmod | grep -E '(^| )sctp( |$)' || echo "WARNING: sctp not loaded"

5G_Core_Network/install_scripts/install_yq.sh renamed to 5G_Core_Network/install_scripts/ensure_consistent_yq.sh

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,26 @@
2828
# damage to property. The software developed by NIST employees is not subject to
2929
# copyright protection within the United States.
3030

31-
echo "# Script: $(realpath $0)..."
31+
# Exit immediately if a command fails
32+
set -e
33+
34+
YQ_VERSION="v4.47.2"
3235

33-
# Uninstall yq with: sudo rm -rf /usr/local/bin/yq; hash -r && hash -r
3436
if command -v yq &>/dev/null; then
35-
echo "Already installed yq, skipping."
36-
exit 0
37+
# Check that the correct version of yq is installed
38+
if ! yq --version 2>/dev/null | grep -q 'https://github\.com/mikefarah/yq'; then
39+
echo "ERROR: Detected an incompatible yq installation."
40+
echo "Please ensure the Python yq is uninstalled with \"pip uninstall -y yq\", then re-run this script."
41+
exit 1
42+
fi
43+
44+
if yq --version 2>/dev/null | grep -q "$YQ_VERSION"; then
45+
exit 0
46+
fi
47+
48+
echo "Removing incompatible yq..."
49+
sudo rm -rf /usr/local/bin/yq
50+
hash -r
3751
fi
3852

3953
echo "Installing yq..."
@@ -77,12 +91,18 @@ case $(uname -m) in
7791
;;
7892
esac
7993

80-
YQ_URL="https://github.com/mikefarah/yq/releases/latest/download/yq_${ARCH_SUFFIX}.tar.gz"
94+
YQ_URL="https://github.com/mikefarah/yq/releases/download/$YQ_VERSION/yq_${ARCH_SUFFIX}.tar.gz"
8195

8296
# Create a temporary directory for the download
8397
TEMP_DIR=$(mktemp -d)
8498
TEMP_PATH="$TEMP_DIR/yq.tar.gz"
8599

100+
if ! command -v curl &>/dev/null; then
101+
echo "Package \"curl\" not found, installing..."
102+
APTVARS="NEEDRESTART_MODE=l NEEDRESTART_SUSPEND=1 DEBIAN_FRONTEND=noninteractive"
103+
sudo env $APTVARS apt-get install -y curl
104+
fi
105+
86106
echo "Downloading yq from $YQ_URL..."
87107
HTTP_STATUS=$(curl -L -w "%{http_code}" -o "$TEMP_PATH" "$YQ_URL")
88108
if [ "$HTTP_STATUS" -eq 200 ]; then

0 commit comments

Comments
 (0)