Commit 082d98e1 authored by 吴洲洋's avatar 吴洲洋

Update script structure

parent a93a3372
gnb: 192.168.10.10
smf: 192.168.2.189
upf: 192.168.2.216
logSize: 100
\ No newline at end of file
vpp:
system:
gtpu_entry: GigabitEthernet2/6/0
gtpu_export: GigabitEthernet2/7/0
gnb_gtpu_ip: 192.168.10.100
ip_link:
ueip: 192.169.0.0
ueIPPrefix: 24
snatInter: ens33
snatIP: 192.168.2.216
vppHost: ens40
gtpu_entry: ens38
gtpu_export: ens39
startup:
config_system: /home/wu/Documents/upf/scripts/config_system.sh
pci_addr_id_entry: 02:06.0
pci_addr_id_export: 02:07.0
vpp_plugins_path: /usr/lib/x86_64-linux-gnu/vpp_plugins
drive: ixgbe
n4:
gnb: 192.168.10.10
logSize: 100
gnb:
username: root
password: 123456
remoteHost: 192.168.2.128
inter: eno1
smf:
remotehost: 192.168.2.128
oai:
username: root
password: 123456
remoteHost: 192.168.2.63
inter: ens33
udm:
username: root
password: 123456
remoteHost: 192.168.2.63
amf:
username: root
password: 123456
remoteHost: 192.168.2.63
inter: ens33
upf:
username: root
password:
remoteHost: 192.168.2.133
vppinter: enp5s0
n4inter: enp14s0
vppEntry: TenGigabitEthernet2/0/0
vppExport: TenGigabitEthernet2/0/1
gateway: ens4f1
vppWatch: /opt/5gc/support-system/watch/upf_watch
tcpdump: true
reboot: true
runScript: /opt/5gc/support-system/test_start_5g.sh
remotehost: 192.168.2.63
gnb: 192.168.10.10
smf : 192.168.2.63
upf : 192.168.2.216
logSize : 100
gnb:
username: root
password: 123456
remoteHost: 192.168.2.128
inter: eno1
smf:
username: root
password: 123456
remoteHost: 192.168.2.63
inter: ens33
udm:
username: root
password: 123456
remoteHost: 192.168.2.63
amf:
username: root
password: 123456
remoteHost: 192.168.2.63
inter: ens33
upf:
username: root
password:
remoteHost: 192.168.2.133
vppinter: enp5s0
n4inter: enp14s0
vppEntry: TenGigabitEthernet2/0/0
vppExport: TenGigabitEthernet2/0/1
gateway: ens4f1
vppWatch: /opt/5gc/support-system/watch/upf_watch
tcpdump: true
reboot: true
runScript: /opt/5gc/support-system/test_start_5g.sh
set interface state @gtpu_entry@ up
set interface ip address @gtpu_entry@ 192.168.10.10/24
create gtpu tunnel src 192.168.10.10 dst @gnb_gtpu_ip@ teid 1 encap-vrf-id 0 decap-next node ip4-lookup
ip route add 192.169.0.0/24 via gtpu_tunnel0
set interface state @gtpu_export@ up
set interface ip address @gtpu_export@ 192.168.30.10/24
ip route add 0.0.0.0/0 via @gtpu_export@
gnb: @gnb@
smf : @smf@
upf : @upf@
logSize : @logSize@
unix {
nodaemon
log /var/log/upf/vpp/vpp.log
full-coredump
gid vpp
cli-listen /run/vpp/cli.sock
exec @CONFIG_SYSTEM@
logsize 100
}
api-trace {
on
}
api-segment {
gid vpp
}
logging
{
default-log-level info
default-syslog-log-level info
}
cpu {
## In the VPP there is one main thread and optionally the user can create worker(s)
## The main thread and worker thread(s) can be pinned to CPU core(s) manually or automatically
## Manual pinning of thread(s) to CPU core(s)
## Set logical CPU core where main thread runs, if main core is not set
## VPP will use core 1 if available
main-core @CORENUMBER@
## Set logical CPU core(s) where worker threads are running
#corelist-workers 2-3
#corelist-io 3,4
## Automatic pinning of thread(s) to CPU core(s)
## Sets number of CPU core(s) to be skipped (1 ... N-1)
## Skipped CPU core(s) are not used for pinning main thread and working thread(s).
## The main thread is automatically pinned to the first available CPU core and worker(s)
## are pinned to next free CPU core(s) after core assigned to main thread
# skip-cores 4
## Specify a number of workers to be created
## Workers are pinned to N consecutive CPU cores while skipping "skip-cores" CPU core(s)
## and main thread's CPU core
#workers 2
## Set scheduling policy and priority of main and worker threads
## Scheduling policy options are: other (SCHED_OTHER), batch (SCHED_BATCH)
## idle (SCHED_IDLE), fifo (SCHED_FIFO), rr (SCHED_RR)
scheduler-policy fifo
## Scheduling priority is used only for "real-time policies (fifo and rr),
## and has to be in the range of priorities supported for a particular policy
scheduler-priority 50
}
# buffers {
## Increase number of buffers allocated, needed only in scenarios with
## large number of interfaces and worker threads. Value is per numa node.
## Default is 16384 (8192 if running unpriviledged)
# buffers-per-numa 128000
## Size of buffer data area
## Default is 2048
# default data-size 2048
# }
dpdk {
## Change default settings for all interfaces
dev default {
## Number of receive queues, enables RSS
## Default is 1
## Number of transmit queues, Default is equal
## to number of worker threads or 1 if no workers treads
## Number of descriptors in transmit and receive rings
## increasing or reducing number can impact performance
## Default is 1024 for both rx and tx
# num-rx-desc 512
# num-tx-desc 512
## VLAN strip offload mode for interface
## Default is off
# vlan-strip-offload on
}
## Whitelist specific interface by specifying PCI address
#82576 1G
dev @PCI_ADDR_ID_ENTRY@
dev @PCI_ADDR_ID_EXPORT@
## Whitelist specific interface by specifying PCI address and in
## addition specify custom parameters for this interface
# dev 0000:02:00.1 {
# num-rx-queues 2
# }
## Change UIO driver used by VPP, Options are: igb_uio, vfio-pci,
## uio_pci_generic or auto (default)
uio-driver vfio-pci
#uio-driver igb_uio
## Disable multi-segment buffers, improves performance but
## disables Jumbo MTU support
#no-multi-seg
## Change hugepages allocation per-socket, needed only if there is need for
## larger number of mbufs. Default is 256M on each detected CPU socket
socket-mem 2048,2048
## Disables UDP / TCP TX checksum offload. Typically needed for use
## faster vector PMDs (together with no-multi-seg)
#no-tx-checksum-offload
}
plugins {
path @VPP_PLUGINS_PATH@
plugin dpdk_plugin.so { enable }
plugin gtpu_plugin.so { enable }
plugin upf_plugin.so { enable }
}
#!/bin/bash
base=$(cd $(dirname $0); pwd)
current="$PWD"
base=$(dirname "$PWD")
arp="$base/src/setuniarp"
configure="$base/etc"
UEIP=""
PREFIX=""
INTER=""
MAC=""
VPPEXPORT=""
UEIP=192.169.0.0
PREFIX=24
INTER=enp5s0f1
MAC=
VPPEXPORT=192.168.30.10
function init_configure() {
UEIP=$($current/yq r $configure/configure.yaml vpp.ip_link.ueip)
PREFIX=$($current/yq r $configure/configure.yaml vpp.ip_link.ueIPPrefix)
INTER=$($current/yq r $configure/configure.yaml vpp.ip_link.vppHost)
VPPEXPORT=$($current/yq r $configure/configure.yaml vpp.ip_link.vppHostIP)
MAC=$(ifconfig $INTER|grep ether|awk '{print $2}')
}
function arp_run(){
echo "$base"
echo "$UEIP"
echo "$PREFIX"
echo "$INTER"
echo "$MAC"
echo "$VPPEXPORT"
echo "$arp"/setuniarp $INTER $MAC "$UEIP/$PREFIX" $VPPEXPORT
"$arp"/setuniarp $INTER $MAC "$UEIP/$PREFIX" $VPPEXPORT
}
#./setuniarp vppout de:dd:91:00:f6:42 192.169.0.0/24
echo "$base"/setuniarp $INTER $MAC "$UEIP/$PREFIX"
"$base"/setuniarp $INTER $MAC "$UEIP/$PREFIX" $VPPEXPORT
init_configure
arp_run
set interface state GigabitEthernet2/6/0 up
set interface ip address GigabitEthernet2/6/0 192.168.10.10/24
create gtpu tunnel src 192.168.10.10 dst 192.168.10.100 teid 1 encap-vrf-id 0 decap-next node ip4-lookup
ip route add 192.169.0.0/24 via gtpu_tunnel0
set interface state GigabitEthernet2/7/0 up
set interface ip address GigabitEthernet2/7/0 192.168.30.10/24
ip route add 0.0.0.0/0 via GigabitEthernet2/7/0
#!/bin/bash
<<!
install buptvppe;
!
PWD="/opt/5gc/upf"
install_buptvppe ()
{
#Directly overwrite, no need to delete
#clear old buptvppe install lib;
#sudo rm -rf /usr/bin/vpp*
#sudo rm -rf /usr/lib/x86_64-linux-gnu/vpp_plugins;
#sudo rm -rf /usr/include/vpp_plugins;
#echo "delete old buptvppe lib finished!!!"
#sleep 1;
#unpack
echo "unpack buptvpp.tar.gz start..."
sudo tar -zxvf $PWD/buptvppe.tar.gz -C $PWD > /dev/null 2>&1;
echo "unpack buptvpp.tar.gz finished!!!"
sleep 1;
#install
echo "install buptvppe start..."
sudo dpkg -i $PWD/build-root/*.deb > /dev/null 2>&1;
sudo systemctl disable vpp;
#rm install package
sudo rm -rf $PWD/build-root;
sudo rm -rf $PWD/buptvppe.tar.gz;
sleep 1;
echo "install buptvppe finished!!!"
return 0
}
function main()
{
install_buptvppe
return 0
}
main
#!/bin/bash
<<!
compile dpdk-20.02, insmod igb_uio.ko;
!
PWD="/opt/5gc/upf"
exec_result()
{
if [ $1 -ne 0 ]; then
echo "insmod vfio-pci.ko false"
exit
fi
echo "insmod vfio-pci.ko success!!!"
return 0;
}
insmod_kmod()
{
sudo modprobe vfio-pci;
insmod_result=$?
exec_result $insmod_result
#sudo rm -rf $PWD/dpdk_lib.tar.gz;
return 0;
}
function main()
{
insmod_kmod
return 0
}
main
#!/bin/bash
UE_IP=192.169.0.0
UE_IP_PREFIX=24
SNAT_INTER=enp67s0f0
SNAT_IP=192.168.2.129
VPPHOST=enp5s0f1
DPDK_EXPORT=enp3s0f0
DPDK_ENTRY=enp3s0f1
UE_IP=""
UE_IP_PREFIX=""
SNAT_INTER=""
SNAT_IP=""
VPPHOST=""
DPDK_EXPORT=""
DPDK_ENTRY=""
current="$PWD"
base=$(dirname "$PWD")
arp="$base/src/setuniarp"
configure="$base/etc"
function init_configure() {
UE_IP=$($current/yq r $configure/configure.yaml vpp.ip_link.ueip)
UE_IP_PREFIX=$($current/yq r $configure/configure.yaml vpp.ip_link.ueIPPrefix)
SNAT_INTER=$($current/yq r $configure/configure.yaml vpp.ip_link.snatInter)
SNAT_IP=$($current/yq r $configure/configure.yaml vpp.ip_link.snatIP)
VPPHOST=$($current/yq r $configure/configure.yaml vpp.ip_link.vppHost)
DPDK_EXPORT=$($current/yq r $configure/configure.yaml vpp.ip_link.gtpu_export)
DPDK_ENTRY=$($current/yq r $configure/configure.yaml vpp.ip_link.gtpu_entry)
}
function run_nat(){
echo "$UE_IP"
echo "$UE_IP_PREFIX"
echo "$SNAT_INTER"
......@@ -15,18 +31,9 @@ echo "$SNAT_IP"
echo "$VPPHOST"
echo "$DPDK_EXPORT"
echo "$DPDK_ENTRY"
echo start_ip_link `date` >> /opt/5gc/upf/ip_link.log
sudo ifconfig $DPDK_EXPORT down
sudo ifconfig $DPDK_ENTRY down
#vpphost
#sudo ifconfig $VPPHOST 192.168.30.11 up;
#sudo ifconfig $VPPHOST mtu 1400 up;
#sudo route add -net "$UE_IP/$UE_IP_PREFIX" dev $VPPHOST
#sudo route add -net "$UE_IP/$UE_IP_PREFIX" gateway 192.168.30.10
#nat interface
#sudo ifconfig "$SNAT_INTER" mtu 1400 up;
sudo ethtool -K "$SNAT_INTER" gro off;
sudo ethtool -K "$SNAT_INTER" tso off;
sudo ethtool -K "$SNAT_INTER" sg off;
......@@ -41,5 +48,7 @@ iptables -t mangle -A POSTROUTING -p tcp --tcp-flags SYN,RST SYN -o "$SNAT_INTER
#system
echo "1" > /proc/sys/net/ipv4/ip_forward
echo end_ip_link `date` >> /opt/5gc/upf/ip_link.log
}
init_configure
run_nat
#!/bin/bash
current="$PWD"
base=$(dirname "$PWD")
configure="$base/etc"
config_system=""
VPPPROCESS="vpp"
VPPCMD="/usr/bin/vpp -c /etc/vpp/startup_debug.conf"
N4PROCESS="main"
N4CMD="$base/src/upf-n4/cmd/upf/main -f $configure/n4_config.yaml"
INSTALLDPDK="$current/install_dpdk_kmod.sh"
IPLINK="$current/nat_config.sh"
function init_configure(){
config_system=$($current/yq r $configure/configure.yaml vpp.startup.config_system)
$current/configure -i $configure -o $configure
mv $configure/config_system.sh $config_system
mv $configure/startup_debug.conf /etc/vpp
}
function start_vpp() {
cmd="$VPPCMD"
installDPDK="$INSTALLDPDK"
iplink="$IPLINK"
$iplink
$installDPDK
echo Y | sudo tee /sys/module/vfio/parameters/enable_unsafe_noiommu_mode
$cmd >/dev/null 2>&1 &
sleep 10s
pid=$(pidof $VPPPROCESS)
if test -z "$pid"; then
echo "vpp startup failed"
exit 1
else
echo "vpp $pid startup success"
exit 2
fi
}
function close_vpp() {
pid=$(pidof $VPPPROCESS)
if test -z "$pid"; then
echo "vpp $pid is not startup"
exit 1
else
echo "kill vpp $pid"
kill -9 ${pid}
exit 2
fi
}
function start_n4() {
cmd="$N4CMD"
$cmd >/dev/null 2>&1 &
sleep 1s
pid2=$(pidof $N4PROCESS)
if test -z "$pid2"; then
echo "n4 startup failed"
exit 1
else
echo "n4 $pid2 startup success"
exit 2
fi
}
function close_n4() {
pid=$(pidof $N4PROCESS)
if test -z "$pid"; then
echo "n4 $pid is not startup"
exit 1
else
echo "kill n4 $pid"
kill -9 ${pid}
exit 2
fi
}
function main() {
init_configure
until [ -z "$1" ]; do
case "$1" in
--start_vpp)
start_vpp
shift
;;
--start_n4)
start_n4
shift
;;
--start_arp)
start_arp
shift
;;
--close_vpp)
close_vpp
shift
;;
--close_n4)
close_n4
shift
;;
--close_arp)
close_arp
shift
;;
esac
done
exit 0
}
main "$@"
File added
#!/bin/bash
base=$(cd $(dirname $0); pwd)
UEIP=192.169.0.0
PREFIX=24
INTER=enp5s0f1
MAC=
VPPEXPORT=192.168.30.10
echo "$base"
echo "$UEIP"
echo "$PREFIX"
echo "$INTER"
echo "$MAC"
#./setuniarp vppout de:dd:91:00:f6:42 192.169.0.0/24
echo "$base"/setuniarp $INTER $MAC "$UEIP/$PREFIX"
"$base"/setuniarp $INTER $MAC "$UEIP/$PREFIX" $VPPEXPORT
#!/bin/bash
UE_IP=192.169.0.0
UE_IP_PREFIX=24
SNAT_INTER=enp67s0f0
SNAT_IP=192.168.2.129
VPPHOST=enp5s0f1
DPDK_EXPORT=enp3s0f0
DPDK_ENTRY=enp3s0f1
echo "$UE_IP"
echo "$UE_IP_PREFIX"
echo "$SNAT_INTER"
echo "$SNAT_IP"
echo "$VPPHOST"
echo "$DPDK_EXPORT"
echo "$DPDK_ENTRY"
echo start_ip_link `date` >> /opt/5gc/upf/ip_link.log
sudo ifconfig $DPDK_EXPORT down
sudo ifconfig $DPDK_ENTRY down
#vpphost
#sudo ifconfig $VPPHOST 192.168.30.11 up;
#sudo ifconfig $VPPHOST mtu 1400 up;
#sudo route add -net "$UE_IP/$UE_IP_PREFIX" dev $VPPHOST
#sudo route add -net "$UE_IP/$UE_IP_PREFIX" gateway 192.168.30.10
#nat interface
#sudo ifconfig "$SNAT_INTER" mtu 1400 up;
sudo ethtool -K "$SNAT_INTER" gro off;
sudo ethtool -K "$SNAT_INTER" tso off;
sudo ethtool -K "$SNAT_INTER" sg off;
#del
sudo iptables -t nat -D POSTROUTING -s "$UE_IP/$UE_IP_PREFIX" -j SNAT --to-source "$SNAT_IP"
iptables -t mangle -D POSTROUTING -p tcp --tcp-flags SYN,RST SYN -o "$SNAT_INTER" -j TCPMSS --set-mss 1300
#add
sudo iptables -t nat -A POSTROUTING -s "$UE_IP/$UE_IP_PREFIX" -j SNAT --to-source "$SNAT_IP"
iptables -t mangle -A POSTROUTING -p tcp --tcp-flags SYN,RST SYN -o "$SNAT_INTER" -j TCPMSS --set-mss 1300
#system
echo "1" > /proc/sys/net/ipv4/ip_forward
echo end_ip_link `date` >> /opt/5gc/upf/ip_link.log
这个文件调用 arp_config、nat_config等脚本,实现统一的upf配置。
\ No newline at end of file
File added
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment