Added startup scripts for gNodeB

This commit is contained in:
madrigal 2025-09-10 13:36:00 -04:00
parent a035788ef3
commit 9973c15234
3 changed files with 124 additions and 0 deletions

8
scripts/iptun.sh Executable file
View File

@ -0,0 +1,8 @@
sudo ip tuntap add name ogstun mode tun
sudo ip addr add 10.45.0.1/16 dev ogstun
sudo ip link set ogstun up
sudo sysctl -w net.ipv4.ip_forward=1
### Add NAT Rule
sudo iptables -t nat -A POSTROUTING -s 10.45.0.0/16 ! -o ogstun -j MASQUERADE
sudo ufw disable

30
scripts/setup.sh Executable file
View File

@ -0,0 +1,30 @@
#!/bin/bash
set -e
# Run local setup scripts
./iptun.sh
./srsran_performance.sh
# Start core container
docker start core
# Run commands inside core container
docker exec -d core bash -c "
cd /etc/open5gs && \
systemctl start mongod && \
./go.sh
"
# Start ran container
docker start ran
# Check if gnb tmux session exists inside ran container
docker exec -it ran bash -c '
if tmux has-session -t gnb 2>/dev/null; then
echo "Attaching to existing gnb session..."
exec tmux attach -t gnb
else
echo "Starting new gnb session..."
exec tmux new-session -s gnb "gnb -c gnb.yaml"
fi
'

86
scripts/srsran_performance.sh Executable file
View File

@ -0,0 +1,86 @@
#!/bin/bash
#
# Copyright 2021-2025 Software Radio Systems Limited
#
# This file is part of srsRAN
#
# srsRAN is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# srsRAN is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# A copy of the GNU Affero General Public License can be found in
# the LICENSE file in the top-level directory of this distribution
# and at http://www.gnu.org/licenses/.
#
#
# This script attempts to automate some typical troubleshooting
# when using machines with lower processing power.
#
# It does the following:
# 1. Set the scaling governor to performance
# 2. Disable DRM KMS polling
# 3. Tune network buffers (Ethernet based USRPs only).
#
set -o errexit
set -o nounset
set -o pipefail
#
# Set the scaling governor to performance.
# See: https://docs.kernel.org/admin-guide/pm/cpufreq.html#generic-scaling-governors
#
set_performance_governor() {
read -e -p "Would you like to set the CPU governor to performance: [Y/n]: " choice
if ! [[ "$choice" == [Yy]* || "$choice" == "" ]]; then
echo "Did not set scaling governor"
return
fi
echo performance | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor >/dev/null
echo "Scaling governor set to performance"
}
#
# DRM KMS polling can sometimes be expensive. Disabling it can sometimes help performance.
# See: https://wiki.archlinux.org/title/kernel_mode_setting#Problem_upon_bootloading_and_dmesg
#
set_kms_polling() {
read -e -p "Would you like to disable KMS polling: [Y/n]: " choice
if ! [[ "$choice" == [Yy]* || "$choice" == "" ]]; then
echo "Did not disable KMS polling"
return
fi
echo N | sudo tee /sys/module/drm_kms_helper/parameters/poll >/dev/null
echo "Disabled DRM KMS polling"
}
#
# Set network buffer size, for USRPs connected over Ethernet.
# See: https://kb.ettus.com/USRP_Host_Performance_Tuning_Tips_and_Tricks
#
set_network_buffers() {
read -e -p "Would you like to tweak the network buffer sizes: [Y/n]: " choice
if ! [[ "$choice" == [Yy]* || "$choice" == "" ]]; then
echo "Did not tweak network buffer sizes"
return
fi
sudo sysctl -w net.core.wmem_max=33554432
sudo sysctl -w net.core.rmem_max=33554432
sudo sysctl -w net.core.wmem_default=33554432
sudo sysctl -w net.core.rmem_default=33554432
echo "Tweaked network buffer sizes"
}
#Check for sudo rights
sudo -v || exit
set_performance_governor
set_kms_polling
set_network_buffers