This commit is contained in:
2026-01-08 09:17:26 +00:00
parent 85fef10860
commit cf4ca86169
35 changed files with 2493 additions and 118 deletions
@@ -0,0 +1,176 @@
# OAI gNB configuration for rfsimulator with Open5GS
# 2x2 MIMO configuration for antenna muting testing
Active_gNBs = ( "gNB-OAI-Open5GS");
Asn1_verbosity = "none";
gNBs =
(
{
////////// Identification parameters:
gNB_ID = 0xe00;
gNB_name = "gNB-OAI-Open5GS";
// Tracking area code, 0x0000 and 0xfffe are reserved values
tracking_area_code = 1;
// Match Open5GS PLMN: MCC=999, MNC=70
plmn_list = ({ mcc = 999; mnc = 70; mnc_length = 2; snssaiList = ({ sst = 1 }) });
nr_cellid = 12345678L;
////////// Physical parameters:
// 2x2 MIMO configuration
pdsch_AntennaPorts_XP = 2;
pusch_AntennaPorts = 2;
do_CSIRS = 1;
do_SRS = 1;
min_rxtxtime = 6;
servingCellConfigCommon = (
{
physCellId = 0;
# Band 78, 106 PRBs, 30kHz SCS
absoluteFrequencySSB = 621312;
dl_frequencyBand = 78;
dl_absoluteFrequencyPointA = 620040;
dl_offstToCarrier = 0;
dl_subcarrierSpacing = 1;
dl_carrierBandwidth = 106;
initialDLBWPlocationAndBandwidth = 28875;
initialDLBWPsubcarrierSpacing = 1;
initialDLBWPcontrolResourceSetZero = 11;
initialDLBWPsearchSpaceZero = 0;
ul_frequencyBand = 78;
ul_offstToCarrier = 0;
ul_subcarrierSpacing = 1;
ul_carrierBandwidth = 106;
pMax = 20;
initialULBWPlocationAndBandwidth = 28875;
initialULBWPsubcarrierSpacing = 1;
# RACH Configuration
prach_ConfigurationIndex = 98;
prach_msg1_FDM = 0;
prach_msg1_FrequencyStart = 0;
zeroCorrelationZoneConfig = 12;
preambleReceivedTargetPower = -104;
preambleTransMax = 6;
powerRampingStep = 1;
ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR = 4;
ssb_perRACH_OccasionAndCB_PreamblesPerSSB = 15;
ra_ContentionResolutionTimer = 7;
rsrp_ThresholdSSB = 19;
prach_RootSequenceIndex_PR = 2;
prach_RootSequenceIndex = 1;
msg1_SubcarrierSpacing = 1,
restrictedSetConfig = 0,
msg3_DeltaPreamble = 1;
p0_NominalWithGrant = -90;
# PUCCH Configuration
pucchGroupHopping = 0;
hoppingId = 40;
p0_nominal = -90;
ssb_PositionsInBurst_Bitmap = 1;
ssb_periodicityServingCell = 2;
dmrs_TypeA_Position = 0;
subcarrierSpacing = 1;
# TDD Configuration (5ms period)
referenceSubcarrierSpacing = 1;
dl_UL_TransmissionPeriodicity = 6;
nrofDownlinkSlots = 7;
nrofDownlinkSymbols = 6;
nrofUplinkSlots = 2;
nrofUplinkSymbols = 4;
ssPBCH_BlockPower = -25;
}
);
# ------- SCTP definitions
SCTP :
{
SCTP_INSTREAMS = 2;
SCTP_OUTSTREAMS = 2;
};
////////// AMF parameters (Open5GS default):
amf_ip_address = ({ ipv4 = "127.0.0.5"; });
NETWORK_INTERFACES :
{
GNB_IPV4_ADDRESS_FOR_NG_AMF = "127.0.0.1";
GNB_IPV4_ADDRESS_FOR_NGU = "127.0.0.1";
GNB_PORT_FOR_S1U = 2152;
};
}
);
MACRLCs = (
{
num_cc = 1;
tr_s_preference = "local_L1";
tr_n_preference = "local_RRC";
pusch_TargetSNRx10 = 200;
pucch_TargetSNRx10 = 200;
}
);
L1s = (
{
num_cc = 1;
tr_n_preference = "local_mac";
prach_dtx_threshold = 120;
tx_amp_backoff_dB = 20;
}
);
RUs = (
{
local_rf = "yes"
nb_tx = 2
nb_rx = 2
att_tx = 0
att_rx = 0;
bands = [78];
max_pdschReferenceSignalPower = -27;
max_rxgain = 75;
eNB_instances = [0];
}
);
rfsimulator :
{
serveraddr = "server";
serverport = 4043;
options = ();
modelname = "AWGN";
};
security = {
ciphering_algorithms = ( "nea0" );
integrity_algorithms = ( "nia2", "nia0" );
drb_ciphering = "yes";
drb_integrity = "no";
};
log_config :
{
global_log_level = "info";
hw_log_level = "info";
phy_log_level = "info";
mac_log_level = "info";
rlc_log_level = "info";
pdcp_log_level = "info";
rrc_log_level = "info";
ngap_log_level = "info";
f1ap_log_level = "info";
};
@@ -0,0 +1,246 @@
#!/bin/bash
# O-RAN Antenna Muting Test Script
# Tests MIMO antenna muting with rfsimulator and Open5GS
set -e
OAI_DIR="/home/maki/openairinterface5g"
BUILD_DIR="$OAI_DIR/cmake_targets/ran_build/build"
CONF_DIR="$OAI_DIR/targets/PROJECTS/GENERIC-NR-5GC/CONF"
GNB_CONF="$CONF_DIR/gnb.sa.band78.2x2.rfsim.open5gs.conf"
UE_CONF="$CONF_DIR/ue.open5gs.conf"
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'
print_status() {
echo -e "${GREEN}[INFO]${NC} $1"
}
print_warning() {
echo -e "${YELLOW}[WARN]${NC} $1"
}
print_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
check_open5gs() {
print_status "Checking Open5GS services..."
for service in amf upf smf; do
if ! systemctl is-active --quiet open5gs-${service}d; then
print_error "Open5GS $service is not running"
print_status "Starting Open5GS services..."
sudo systemctl start open5gs-amfd open5gs-upfd open5gs-smfd open5gs-nrfd
sleep 2
fi
done
print_status "Open5GS services are running"
}
setup_network() {
print_status "Setting up network routing for UE..."
# Enable IP forwarding
sudo sysctl -w net.ipv4.ip_forward=1 > /dev/null
# Add NAT for UE traffic (if not already added)
if ! sudo iptables -t nat -C POSTROUTING -s 10.45.0.0/16 ! -o ogstun -j MASQUERADE 2>/dev/null; then
sudo iptables -t nat -A POSTROUTING -s 10.45.0.0/16 ! -o ogstun -j MASQUERADE
print_status "Added NAT rule for UE subnet"
fi
}
start_gnb() {
print_status "Starting gNB with 2x2 MIMO configuration..."
print_status "Antenna control server will be available on port 9999"
cd $BUILD_DIR
sudo ./nr-softmodem -O $GNB_CONF --sa --rfsim 2>&1 | tee /tmp/gnb.log &
GNB_PID=$!
print_status "gNB started with PID $GNB_PID"
echo $GNB_PID > /tmp/gnb.pid
# Wait for gNB to initialize
sleep 5
}
start_ue() {
print_status "Starting UE..."
cd $BUILD_DIR
sudo ./nr-uesoftmodem -r 106 --numerology 1 --band 78 -C 3319680000 \
--rfsim --sa -O $UE_CONF 2>&1 | tee /tmp/ue.log &
UE_PID=$!
print_status "UE started with PID $UE_PID"
echo $UE_PID > /tmp/ue.pid
# Wait for UE to attach
sleep 10
}
check_connection() {
print_status "Checking UE connection..."
# Check if oaitun_ue1 interface exists
if ip link show oaitun_ue1 &>/dev/null; then
print_status "UE TUN interface is up"
UE_IP=$(ip addr show oaitun_ue1 | grep 'inet ' | awk '{print $2}' | cut -d/ -f1)
print_status "UE IP: $UE_IP"
return 0
else
print_warning "UE TUN interface not found yet"
return 1
fi
}
run_iperf_test() {
print_status "Running iperf test..."
# Start iperf server on UPF side
iperf3 -s -B 10.45.0.1 -D &>/dev/null &
IPERF_SRV_PID=$!
sleep 1
# Run iperf client from UE
print_status "Testing downlink throughput..."
sudo ip netns exec ue_ns iperf3 -c 10.45.0.1 -t 5 -R 2>/dev/null || \
iperf3 -c 10.45.0.1 -t 5 -R 2>/dev/null || \
print_warning "iperf test failed or UE not fully connected"
kill $IPERF_SRV_PID 2>/dev/null || true
}
test_antenna_muting() {
print_status "Testing antenna muting via control interface..."
# Wait for control server to be ready
sleep 2
# Get initial status
print_status "Initial antenna status:"
echo "STATUS" | nc -w 2 localhost 9999 || print_warning "Control server not responding"
echo ""
print_status "Muting TX antenna 1..."
echo "MUTE TX 1" | nc -w 2 localhost 9999 || true
sleep 1
print_status "Current antenna status after muting:"
echo "STATUS" | nc -w 2 localhost 9999 || true
echo ""
print_status "Statistics:"
echo "STATS" | nc -w 2 localhost 9999 || true
echo ""
print_status "Restoring TX antenna 1..."
echo "UNMUTE TX 1" | nc -w 2 localhost 9999 || true
echo ""
print_status "Final antenna status:"
echo "STATUS" | nc -w 2 localhost 9999 || true
}
cleanup() {
print_status "Cleaning up..."
if [ -f /tmp/gnb.pid ]; then
sudo kill $(cat /tmp/gnb.pid) 2>/dev/null || true
rm /tmp/gnb.pid
fi
if [ -f /tmp/ue.pid ]; then
sudo kill $(cat /tmp/ue.pid) 2>/dev/null || true
rm /tmp/ue.pid
fi
# Kill any remaining processes
sudo pkill -f nr-softmodem 2>/dev/null || true
sudo pkill -f nr-uesoftmodem 2>/dev/null || true
print_status "Cleanup complete"
}
show_usage() {
echo "O-RAN Antenna Muting Test Script"
echo ""
echo "Usage: $0 [command]"
echo ""
echo "Commands:"
echo " all - Run full test (gNB + UE + iperf + antenna muting)"
echo " gnb - Start gNB only"
echo " ue - Start UE only (requires gNB running)"
echo " mute - Test antenna muting (requires gNB running)"
echo " iperf - Run iperf test (requires gNB + UE running)"
echo " status - Check antenna status"
echo " cleanup - Stop all processes"
echo ""
echo "Antenna Control Commands (via nc localhost 9999):"
echo " MUTE TX <id> - Mute TX antenna"
echo " UNMUTE TX <id> - Unmute TX antenna"
echo " SET TX MASK <hex> - Set TX antenna bitmask"
echo " STATUS - Get current status"
echo " STATS - Get statistics"
echo " HELP - Show all commands"
}
# Main
case "${1:-all}" in
all)
trap cleanup EXIT
check_open5gs
setup_network
start_gnb
start_ue
# Wait for connection
for i in {1..30}; do
if check_connection; then
break
fi
sleep 2
done
test_antenna_muting
run_iperf_test
print_status "Test complete. Press Ctrl+C to exit."
wait
;;
gnb)
check_open5gs
setup_network
start_gnb
print_status "gNB running. Press Ctrl+C to stop."
wait
;;
ue)
start_ue
print_status "UE running. Press Ctrl+C to stop."
wait
;;
mute)
test_antenna_muting
;;
iperf)
run_iperf_test
;;
status)
echo "STATUS" | nc -w 2 localhost 9999
;;
cleanup)
cleanup
;;
*)
show_usage
;;
esac
@@ -0,0 +1,51 @@
# OAI nrUE configuration for rfsimulator with Open5GS
# IMSI matching subscriber registered in Open5GS
uicc0 = {
imsi = "999700000000001";
key = "fec86ba6eb707ed08905757b1bb44b8f";
opc = "C42449363BBAD02B66D16BC975D77CC1";
dnn = "internet";
nssai_sst = 1;
}
thread-pool = "-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1"
# Channel model configuration for rfsimulator
channelmod = {
max_chan = 10;
modellist = "modellist_rfsimu_1";
modellist_rfsimu_1 = (
{ # DL channel
model_name = "rfsimu_channel_enB0"
type = "AWGN";
ploss_dB = 20;
noise_power_dB = -4;
forgetfact = 0;
offset = 0;
ds_tdl = 0;
},
{ # UL channel
model_name = "rfsimu_channel_ue0"
type = "AWGN";
ploss_dB = 20;
noise_power_dB = -2;
forgetfact = 0;
offset = 0;
ds_tdl = 0;
}
);
};
log_config :
{
global_log_level = "info";
hw_log_level = "info";
phy_log_level = "info";
mac_log_level = "info";
rlc_log_level = "info";
pdcp_log_level = "info";
rrc_log_level = "info";
nas_log_level = "info";
};