Skip to content

Commit 14ee6b4

Browse files
committed
Tag v1.5.0-2
1 parent f5badc0 commit 14ee6b4

13 files changed

Lines changed: 170 additions & 22 deletions

File tree

Next_Generation_Node_B/run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ graceful_shutdown() {
4646
./stop.sh
4747
exit
4848
}
49-
trap graceful_shutdown SIGINT
49+
trap graceful_shutdown SIGINT SIGTERM SIGQUIT
5050

5151
if pgrep -x "gnb" >/dev/null; then
5252
echo "Already running gnb."

OpenAirInterface_Testbed/Next_Generation_Node_B/install_scripts/revert_du_namespace.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ echo "# Script: $(realpath "$0")..."
3434
set +e
3535

3636
SCRIPT_DIR=$(dirname "$(realpath "$0")")
37+
cd "$SCRIPT_DIR"
3738

3839
DU_NUMBER=$1
3940

@@ -51,10 +52,8 @@ DU_NAMESPACE="du$DU_NUMBER"
5152

5253
# Give the DU its own network namespace and configure it to access the host network
5354
NETWORK_INTERFACE=$(ip route | grep default | awk '{print $5}')
54-
DU_INDEX=$((DU_NUMBER - 1))
55-
5655
# Fetch the base IP using the Python script
57-
BASE_IP=$(python3 fetch_nth_ip.py 0.10.202.0/24 $DU_INDEX)
56+
BASE_IP=$(python3 fetch_nth_ip.py 0.10.202.0/24 $((DU_NUMBER - 1)))
5857
DU_SUBNET_FIRST_3_OCTETS=$(echo $BASE_IP | cut -d. -f2-4)
5958
DU_HOST_IP=$DU_SUBNET_FIRST_3_OCTETS.1
6059
DU_NS_IP=$DU_SUBNET_FIRST_3_OCTETS.2

OpenAirInterface_Testbed/Next_Generation_Node_B/install_scripts/setup_du_namespace.sh

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,12 @@ DU_NAMESPACE="du$DU_NUMBER"
5252

5353
# Give the DU its own network namespace and configure it to access the host network
5454
NETWORK_INTERFACE=$(ip route | grep default | awk '{print $5}')
55-
DU_INDEX=$((DU_NUMBER - 1))
56-
5755
# Fetch the base IP using the Python script
58-
BASE_IP=$(python3 fetch_nth_ip.py 0.10.202.0/24 $DU_INDEX)
56+
BASE_IP=$(python3 fetch_nth_ip.py 0.10.202.0/24 $((DU_NUMBER - 1)))
5957
DU_SUBNET_FIRST_3_OCTETS=$(echo $BASE_IP | cut -d. -f2-4)
6058
DU_HOST_IP=$DU_SUBNET_FIRST_3_OCTETS.1
6159
DU_NS_IP=$DU_SUBNET_FIRST_3_OCTETS.2
6260

63-
echo "Subnet is $DU_SUBNET_FIRST_3_OCTETS.0/24"
64-
echo "Host IP is $DU_HOST_IP"
65-
echo "Namespace IP is $DU_NS_IP"
66-
exit 0
67-
6861
# Code from (https://open-cells.com/index.php/2021/02/08/rf-simulator-1-enb-2-ues-all-in-one):
6962
sudo ip netns delete $DU_NAMESPACE || true
7063
sudo ip link delete v-eth-du$DU_NUMBER || true

OpenAirInterface_Testbed/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ The script `run_handover_scenario.sh`, based on the handover tutorial [\[4\]][oa
4242
<hr>
4343

4444
<p align="center">
45-
<img src="../Images/F1_Handover_Scenario_Example.png" alt="F1 Handover Scenario Example Output" width="70%">
45+
<img src="../Images/F1_Handover_Scenario_Example.png" alt="F1 Handover Scenario Example Output">
4646
</p>
4747

4848
</details>

OpenAirInterface_Testbed/User_Equipment/generate_configurations.sh

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,17 @@ if [[ -z "$SST" || -z "$SD" || "$SST" == "null" || "$SD" == "null" ]]; then
140140
exit 1
141141
fi
142142

143+
OGSTUN_IPV4=$(yq eval '.ogstun_ipv4' "$YAML_PATH")
144+
OGSTUN_IPV6=$(yq eval '.ogstun_ipv6' "$YAML_PATH")
145+
if [[ "$OGSTUN_IPV4" == "null" || -z "$OGSTUN_IPV4" ]]; then
146+
echo "Missing parameter in "$YAML_PATH": ogstun_ipv4"
147+
exit 1
148+
fi
149+
if [[ "$OGSTUN_IPV6" == "null" || -z "$OGSTUN_IPV6" ]]; then
150+
echo "Missing parameter in "$YAML_PATH": ogstun_ipv6"
151+
exit 1
152+
fi
153+
143154
echo "Saving configuration file example..."
144155
if [ "$CLEAR_CONFIGS" = true ]; then
145156
sudo rm -rf configs
@@ -198,11 +209,19 @@ for UE_NUMBER in "${UE_NUMBERS[@]}"; do
198209
echo "@include \"channelmod_rfsimu.conf\"" >>"configs/ue$UE_NUMBER.conf"
199210
fi
200211

212+
UE_IPV4=""
201213
if [ $UE_NUMBER -gt 3 ]; then
202214
echo "UE is greater than registered subscribers, registering UE $UE_NUMBER..."
203215
REGISTRATION_DIR=$(dirname "$SCRIPT_DIR")/5G_Core_Network/install_scripts
204216
if [ -f "$REGISTRATION_DIR/./register_subscriber.sh" ]; then
205-
"$REGISTRATION_DIR/./register_subscriber.sh" --imsi "$UE_IMSI" --key "$UE_KEY" --opc "$UE_OPC" --apn "$DNN" || true
217+
UE_INDEX=$((UE_NUMBER + 99))
218+
UE_IPV4=$(python3 install_scripts/fetch_nth_ip.py "$OGSTUN_IPV4" "$UE_INDEX")
219+
if [ $? -eq 0 ]; then
220+
IPV4_LINE="--ipv4 $UE_IPV4"
221+
else
222+
IPV4_LINE=""
223+
fi
224+
"$REGISTRATION_DIR/./register_subscriber.sh" --imsi "$UE_IMSI" --key "$UE_KEY" --opc "$UE_OPC" --apn "$DNN" --sst "$SST" --sd "$SD" $IPV4_LINE || true
206225
fi
207226
fi
208227

@@ -216,6 +235,9 @@ for UE_NUMBER in "${UE_NUMBERS[@]}"; do
216235
echo " DNN: $DNN"
217236
echo " SST: $SST"
218237
echo " SD: $SD"
238+
if [ -n "$UE_IPV4" ]; then
239+
echo " IPv4: $UE_IPV4"
240+
fi
219241
echo
220242

221243
echo "The configuration file is located in the configs/ directory."
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/usr/bin/env python3
2+
3+
# Usage:
4+
# fetch_nth_ip.py <subnet> <offset>
5+
6+
# For example:
7+
# fetch_nth_ip.py 192.168.1.0/24 0 returns 192.168.1.1
8+
# fetch_nth_ip.py 2001:db8::/64 0 returns 2001:db8::1
9+
# fetch_nth_ip.py 192.168.1.0/24 10 returns 192.168.1.11
10+
# fetch_nth_ip.py 2001:db8::/64 10 returns 2001:db8::b
11+
12+
import sys
13+
import argparse
14+
import ipaddress
15+
16+
def fetch_nth_address(network_str, offset):
17+
net = ipaddress.ip_network(network_str, strict=False)
18+
assert offset >= 0, "Offset must be non-negative"
19+
20+
if isinstance(net, ipaddress.IPv4Network):
21+
if net.prefixlen == 32:
22+
assert offset == 0, "Offset out of range for single-address subnet."
23+
return net.network_address
24+
if net.prefixlen == 31:
25+
assert offset < 2, "Offset out of range for two-address subnet."
26+
return ipaddress.ip_address(int(net.network_address) + offset)
27+
# Regular IPv4: skip network and broadcast
28+
usable = net.num_addresses - 2
29+
assert offset < usable, f"Offset out of range. Usable range: 0 to {usable-1}"
30+
return ipaddress.ip_address(int(net.network_address) + 1 + offset)
31+
32+
if net.prefixlen == 128: # IPv6
33+
assert offset == 0, "Offset out of range for single-address subnet."
34+
return net.network_address
35+
36+
# Skip the base address by default
37+
usable = net.num_addresses - 1
38+
assert offset < usable, f"Offset out of range. Usable range: 0 to {usable-1}"
39+
return ipaddress.ip_address(int(net.network_address) + 1 + offset)
40+
41+
if __name__ == "__main__":
42+
ap = argparse.ArgumentParser(description="Return the Nth address from a network.")
43+
ap.add_argument("subnet", help="Network in CIDR notation, e.g. 192.168.1.0/24 or 2001:db8::/64")
44+
ap.add_argument("offset", type=int, help="Offset from the first address")
45+
args = ap.parse_args()
46+
try:
47+
ip = fetch_nth_address(args.subnet, args.offset)
48+
print(str(ip))
49+
except Exception as e:
50+
print(f"ERROR: {e}", file=sys.stderr)
51+
sys.exit(1)

OpenAirInterface_Testbed/User_Equipment/install_scripts/revert_ue_namespace.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ echo "# Script: $(realpath "$0")..."
3333
# Do not exit immediately if a command fails
3434
set +e
3535

36+
SCRIPT_DIR=$(dirname "$(realpath "$0")")
37+
cd "$SCRIPT_DIR"
38+
3639
UE_NUMBER=$1
3740

3841
if [[ -z "$UE_NUMBER" ]]; then
@@ -47,8 +50,11 @@ fi
4750

4851
UE_NAMESPACE="ue$UE_NUMBER"
4952

53+
# Give the UE its own network namespace and configure it to access the host network
5054
NETWORK_INTERFACE=$(ip route | grep default | awk '{print $5}')
51-
UE_SUBNET_FIRST_3_OCTETS=10.201.$UE_NUMBER
55+
# Fetch the base IP using the Python script
56+
BASE_IP=$(python3 fetch_nth_ip.py 0.10.201.0/24 $((UE_NUMBER - 1)))
57+
UE_SUBNET_FIRST_3_OCTETS=$(echo $BASE_IP | cut -d. -f2-4)
5258
UE_HOST_IP=$UE_SUBNET_FIRST_3_OCTETS.1
5359
UE_NS_IP=$UE_SUBNET_FIRST_3_OCTETS.2
5460

@@ -58,7 +64,6 @@ sudo ip netns exec $UE_NAMESPACE ip addr del $UE_NS_IP/24 dev v-$UE_NAMESPACE
5864
sudo ip netns exec $UE_NAMESPACE ip link set v-$UE_NAMESPACE down
5965

6066
echo "Removing iptables rules..."
61-
6267
sudo iptables -D FORWARD -o $NETWORK_INTERFACE -i v-eth$UE_NUMBER -j ACCEPT
6368
sudo iptables -D FORWARD -i $NETWORK_INTERFACE -o v-eth$UE_NUMBER -j ACCEPT
6469
sudo iptables -t nat -D POSTROUTING -s $UE_SUBNET_FIRST_3_OCTETS.0/24 -o $NETWORK_INTERFACE -j MASQUERADE

OpenAirInterface_Testbed/User_Equipment/install_scripts/setup_ue_namespace.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ echo "# Script: $(realpath "$0")..."
3333
# Exit immediately if a command fails
3434
set -e
3535

36+
SCRIPT_DIR=$(dirname "$(realpath "$0")")
37+
cd "$SCRIPT_DIR"
38+
3639
UE_NUMBER=$1
3740

3841
if [[ -z "$UE_NUMBER" ]]; then
@@ -49,7 +52,9 @@ UE_NAMESPACE="ue$UE_NUMBER"
4952

5053
# Give the UE its own network namespace and configure it to access the host network
5154
NETWORK_INTERFACE=$(ip route | grep default | awk '{print $5}')
52-
UE_SUBNET_FIRST_3_OCTETS=10.201.$UE_NUMBER
55+
# Fetch the base IP using the Python script
56+
BASE_IP=$(python3 fetch_nth_ip.py 0.10.201.0/24 $((UE_NUMBER - 1)))
57+
UE_SUBNET_FIRST_3_OCTETS=$(echo $BASE_IP | cut -d. -f2-4)
5358
UE_HOST_IP=$UE_SUBNET_FIRST_3_OCTETS.1
5459
UE_NS_IP=$UE_SUBNET_FIRST_3_OCTETS.2
5560

OpenAirInterface_Testbed/User_Equipment/run.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,10 @@ fi
7676
# Function to handle graceful shutdown
7777
graceful_shutdown() {
7878
echo "Shutting down UE $UE_NUMBER gracefully..."
79-
./stop.sh
79+
"$SCRIPT_DIR/stop.sh" $UE_NUMBER
8080
exit
8181
}
82-
trap graceful_shutdown SIGINT
82+
trap graceful_shutdown SIGINT SIGTERM SIGQUIT
8383

8484
# Function to update or add configuration properties in .conf files, considering sections and uncommenting if needed
8585
update_conf() {

OpenAirInterface_Testbed/User_Equipment/run_gdb.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ graceful_shutdown() {
7979
./stop.sh
8080
exit
8181
}
82-
trap graceful_shutdown SIGINT
82+
trap graceful_shutdown SIGINT SIGTERM SIGQUIT
8383

8484
# Function to update or add configuration properties in .conf files, considering sections and uncommenting if needed
8585
update_conf() {

0 commit comments

Comments
 (0)