Commit 67f98f0a authored by Franck Messaoudi's avatar Franck Messaoudi

Update: remove the tests folder

parent c71a1521
#!/bin/bash
# ==============================================
# Author: Franck MESSAOUDI
# email: franck.messaoudi@openairinterface.org
#
# Script for testbed.
# Run the server and client on remote servers.
# Run control plane on dut.
#
# Packages required: tmux
# =============================================
send_keys_trex() {
# Panel 0
tmux send-keys -t "$session_name:0.0" "ssh ${TREX_SERVER_SSH}" C-m
tmux send-keys -t "$session_name:0.0" "cd ${TREX_SERVER_DIR}" C-m
tmux send-keys -t "$session_name:0.0" "./t-rex-64 -i --cfg ${TREX_CONFIG_DIR}/trex-dut-ip-config.yaml" C-m
# Panel 1
tmux send-keys -t "$session_name:0.1" "sleep 7; ssh ${TREX_SERVER_NAME}" C-m
tmux send-keys -t "$session_name:0.1" "cd ${TREX_TEST_CASES_DIR}; python3 run.py -m 100% -p mesfa -f udp -q $3 -d $4" C-m
}
send_keys_upf_logs() {
# Panel 0
tmux send-keys -t "$session_name:1.0" "ssh ${DUT_NAME}" C-m
tmux send-keys -t "$session_name:1.0" "cd ${XDP_DUMP}" C-m
tmux send-keys -t "$session_name:1.0" "sudo ./xdpdump -i enp5s0f1 --use-pcap -w $1/capture_$2_enp5s0f1.pcap" C-m
# Panel 1
tmux send-keys -t "$session_name:1.1" "ssh ${DUT_NAME}" C-m
tmux send-keys -t "$session_name:1.1" "cd ${XDP_DUMP}" C-m
tmux send-keys -t "$session_name:1.1" "sudo ./xdpdump -i enp5s0f0 -w $1/capture_$2_enp5s0f0.pcap" C-m
# Panel 2
tmux send-keys -t "$session_name:1.2" "ssh ${DUT_NAME}" C-m
tmux send-keys -t "$session_name:1.2" "cd ${XDP_MONITOR}" C-m
tmux send-keys -t "$session_name:1.2" "sudo ./xdp-monitor -e >> $1/xdp-monitor_$2.log" C-m
# Panel 3
tmux send-keys -t "$session_name:1.3" "ssh ${DUT_NAME}" C-m
tmux send-keys -t "$session_name:1.3" "mpstat -P ALL 3 >> $1/cpu-usage_$2.log" C-m
}
create_window_trex() {
tmux rename-window -t "$session_name:0" 'TRex'
tmux split-window -h -t "$session_name:0.0"
send_keys_trex "$1" "$2" "$3" "$4"
}
create_window_upf_logs() {
tmux new-window -d -t "$session_name" -n 'UPF_logs'
tmux split-window -h -t "$session_name:1.0"
tmux split-window -h -t "$session_name:1.1"
tmux split-window -v -t "$session_name:1.2"
send_keys_upf_logs "$1" "$2"
}
attach() {
echo "Attaching on session ${session_name}..."
tmux select-pane -t "$session_name:0.0"
tmux -2 attach-session -t "$session_name"
}
force_kill() {
echo "Killing session ${session_name}..."
tmux kill-session -t "$session_name" 2>/dev/null
}
stop() {
echo "Stopping session ${session_name}..."
}
main() {
set -o errexit
set -o pipefail
set -o nounset
# set -x
local -r dirname="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
local -r filename="${dirname}/$(basename "${BASH_SOURCE[0]}")"
local -r session_name="china"
source "${dirname}/../env.sh"
XDP_TOOLS="${WORKSPACE}/xdp-tools"
XDP_DUMP="${XDP_TOOLS}/xdp-dump"
XDP_MONITOR="${XDP_TOOLS}/xdp-monitor"
SCRIPTS="${DUT_UPF_WORKSPACE_STANDALONE}/tests/scripts"
unset TMUX
tmux -2 new-session -d -s "$session_name"
create_window_trex "$1" "$2" "$3" "$4"
create_window_upf_logs "$1" "$2"
attach
stop
force_kill
}
main "$@"
import time
import uuid
from datetime import datetime
from threading import Thread, Event
import scapy.sendrecv
from scapy.contrib.gtp import GTP_U_Header, GTPPDUSessionContainer
from scapy.contrib.pfcp import IE_ApplyAction, IE_CreateFAR, IE_CreatePDR, IE_DestinationInterface, \
IE_FAR_Id, \
IE_ForwardingParameters, IE_FSEID, IE_NetworkInstance, IE_NodeId, IE_PDI, IE_PDR_Id, IE_Precedence, \
IE_RecoveryTimeStamp, IE_SourceInterface, IE_UE_IP_Address, IE_FTEID, IE_OuterHeaderCreation, \
IE_OuterHeaderRemoval, \
PFCP, \
PFCPAssociationSetupRequest, PFCPSessionEstablishmentRequest, \
PFCPSessionModificationRequest, \
IE_CPFunctionFeatures, PFCPSessionEstablishmentResponse, IE_CreatedPDR, IE_QFI, PFCPHeartbeatResponse, \
IE_SequenceNumber, PFCPHeartbeatRequest
from scapy.layers.inet import IP, UDP, ICMP
from scapy.all import sniff
SMF_ID = "172.21.16.89"
SEQ = 16770407
FTEID_UL = 2596996162
UE_IP = "12.1.1.2"
# gNB_IP = "192.168.72.1"
gNB_IP = "192.168.101.3"
def seid():
#return uuid.uuid4().int & (1 << 64) - 1
return 1
def ie_fteid_set(fteid, ipv4):
return IE_FTEID(V4=1, TEID=fteid, ipv4=ipv4)
def ie_fteid():
return IE_FTEID(CH=1, V4=1)
def ie_fteid_ch(chid):
return IE_FTEID(CH=1, CHID=1, choose_id=chid, V4=1)
def outer_header_creation(fteid, ipv4):
return IE_OuterHeaderCreation(
GTPUUDPIPV4=1, TEID=fteid, ipv4=ipv4)
def create_pdr_ul(pdr_id, far_id, nwi, sdf_filter, source_iface, ip, sd):
return IE_CreatePDR(IE_list=[
IE_PDR_Id(id=pdr_id),
IE_Precedence(precedence=0),
IE_PDI(IE_list=[
IE_SourceInterface(interface=source_iface),
ie_fteid_ch(42),
IE_NetworkInstance(instance=nwi),
IE_UE_IP_Address(ipv4=ip, V4=1, SD=sd),
# IE_SDF_Filter(FD=1,
# flow_description=sdf_filter),
# IE_QFI(QFI=8)
]),
IE_OuterHeaderRemoval(header="GTP-U/UDP/IPv4"),
IE_FAR_Id(id=far_id),
])
def create_pdr_dl(pdr_id, far_id, nwi, sdf_filter, source_iface, ip, sd):
return IE_CreatePDR(IE_list=[
IE_PDR_Id(id=pdr_id),
IE_Precedence(precedence=0),
IE_PDI(IE_list=[
IE_SourceInterface(interface=source_iface),
IE_NetworkInstance(instance=nwi),
# IE_SDF_Filter(FD=1, flow_description=sdf_filter),
IE_UE_IP_Address(ipv4=ip, V4=1, SD=sd)
]),
IE_FAR_Id(id=far_id)
])
def create_far_ul(far_id, nwi):
return IE_CreateFAR(IE_list=[
IE_FAR_Id(id=far_id),
IE_ApplyAction(FORW=1),
IE_ForwardingParameters(IE_list=[
# IE_DestinationInterface(interface="SGi-LAN/N6-LAN"),
IE_DestinationInterface(interface="Core"),
IE_NetworkInstance(instance=nwi),
])
])
def create_far_dl(far_id, nwi, fteid, ipv4):
return IE_CreateFAR(IE_list=[
IE_FAR_Id(id=far_id),
IE_ApplyAction(FORW=1),
IE_ForwardingParameters(IE_list=[
IE_DestinationInterface(interface="Access"),
IE_NetworkInstance(instance=nwi),
outer_header_creation(fteid, ipv4)
])
])
def session_establishment_ul(seid_):
return PFCPSessionEstablishmentRequest(IE_list=[
IE_NodeId(id_type="FQDN", id=SMF_ID),
IE_FSEID(seid=seid_, ipv4="172.21.16.89", v4=1),
create_pdr_ul(1, 1, "access.oai.org", "permit out ip from any to assigned", "Access", UE_IP, 0),
create_far_ul(1, "core.oai.org")
])
def session_modification_dl(seid_):
return PFCPSessionModificationRequest(IE_list=[
create_pdr_dl(2, 2, "core.oai.org", "permit out ip from any to assigned", "Core", UE_IP, 1),
create_far_dl(2, "access.oai.org", FTEID_UL, gNB_IP),
# IE_FSEID(seid=seid_, ipv4="192.168.100.2", v4=1),
IE_NodeId(id_type="FQDN", id=SMF_ID)
])
def icmp_request_ul(fteid, dst ="8.8.8.8"):
res = scapy.sendrecv.sr1(IP(src=f"{gNB_IP}", dst="192.168.101.2", flags=["DF"]) /
UDP(sport=2152, dport=2152) / GTP_U_Header(teid=fteid) / GTPPDUSessionContainer(type=1,
QFI=8) /
IP(src=f"{UE_IP}", dst=dst, flags=["DF"]) / ICMP()/(b"1"*48)
)
print(res)
def association():
ts = int((datetime.now() - datetime(1900, 1, 1)).total_seconds())
return (PFCPAssociationSetupRequest(IE_list=[
IE_NodeId(id_type="FQDN", id=SMF_ID),
IE_RecoveryTimeStamp(timestamp=ts),
IE_CPFunctionFeatures(OVRL=1, LOAD=1)
]))
def send_receive_pfcp(msg, seid_=None, recv=True, seq=None):
global SEQ
seq = seq if seq else SEQ
pfcp = PFCP(version=1, seq=seq,
S=0 if seid_ is None else 1,
seid=0 if seid_ is None else seid_)
SEQ += 1
pkt = IP(src="172.21.16.89", dst="172.21.16.89", proto=17) / UDP(sport=8805, dport=8805) / pfcp / msg
# sr1 only returns first answered packet
if recv:
res = scapy.sendrecv.sr1(pkt)
print(res)
return res
else:
scapy.sendrecv.send(pkt)
class Sniffer(Thread):
def __init__(self, if_name, filter, heartbeat=True):
super().__init__()
self.if_name = if_name
self.filter = filter
self.heartbeat = heartbeat
self.stop = Event()
def run(self):
sniff(iface=self.if_name, filter=self.filter, prn=self.callback, store=0, stop_filter=self.should_stop)
def join(self, timeout=None):
self.stop.set()
super().join(timeout)
def callback(self, pkt):
print(f"Received packet: {pkt}")
try:
callback_resp = pkt[PFCPHeartbeatRequest]
seq_number = callback_resp[IE_SequenceNumber].number
send_receive_pfcp(PFCPHeartbeatResponse, recv=False, seq=seq_number)
except IndexError: # also traces other responses
pass
def should_stop(self, packet):
return self.stop.is_set()
def main():
#heartbeat_sniffer = Sniffer(if_name="demo-oai", filter="dst host 192.168.100.2 and udp port 8805")
#icmp_sniffer = Sniffer(if_name="cn5g-access", filter="dst host 192.168.72.1 and icmp")
print("Starting heartbeat and ICMP sniffer in background")
#heartbeat_sniffer.start()
#icmp_sniffer.start()
print("Send PFCP association setup")
send_receive_pfcp(association())
s = seid()
print("Now sleep for 10 seconds while we answer heartbeats")
time.sleep(1)
print("Send PFCP session establishment")
res = send_receive_pfcp(session_establishment_ul(s), seid_=0)
session_resp = res[PFCPSessionEstablishmentResponse]
created_fteid = session_resp[IE_CreatedPDR][IE_FTEID].TEID
print(f"Created FTEID: {hex(created_fteid)}")
time.sleep(1)
print("Send PFCP session modification")
send_receive_pfcp(session_modification_dl(s), seid_=s)
time.sleep(1)
# TODO this hangs currently, because scapy does not find the return value. I really would like to verify here
# if there is a response
#icmp_request_ul(created_fteid, "192.168.73.135")
icmp_request_ul(created_fteid, "8.8.8.8")
time.sleep(1)
if __name__ == "__main__":
main()
UPF_WORKSPACE="${HOME}"/workspace
TREX_WORKSPACE=/tmp/workspace
DUT_UPF_WORKSPACE_STANDALONE="${UPF_WORKSPACE}"/oai-cn5g-upf
DUT_CN_WORKSPACE_STANDALONE="${UPF_WORKSPACE}"/oai-cn5g-fed
CN_DOCKER_COMPOSE_FILE=docker-compose-trex.yaml
UPF_N3_INTERFACE=enp1s0f0np0
UPF_N6_INTERFACE=enp1s0f1np1
DUT_SCAPY="${UPF_WORKSPACE}"/scapy
BPF_SAMPLES_DIR="${DUT_UPF_WORKSPACE_STANDALONE}"/build/samples
BPF_BINARY_DIR="${DUT_UPF_WORKSPACE_STANDALONE}"/build/tests
# Compilation environment variable.
NUM_THREADS=
# Docker environment variable.
USERNAME=upf-bpf
IMAGE_TAG=upf
IMAGE_VERSION=v2.1
DOCKERFILE=Dockerfile
DOCKERCOMPOSEFILE=docker-compose.yml
SSH_FOLDER=~/.ssh
SSH_PUBLIC_KEY_FILE=id_rsa.pub
SSH_PRIVATE_KEY_FILE=id_rsa
SSH_CONFIG_FILE=config
GIT_CONFIG=~/.gitconfig
BASH_RC=~/.bashrc
DEVICE_IN=
DEVICE_OUT_UL=
DEVICE_OUT_DL=
# TODO navarrothiago - pass as exec param.
GTP_INTERFACE=
UDP_INTERFACE=
SOCKET_BUFFER_ENABLED=0
# Test environment variables.
TEST_CASE=hello_world
GTEST_FILTER_ARGS="*.*"
########################################################
############## Trex Server Configuration ###############
########################################################
JUMP_SERVER_NAME="trex"
JUMP_SERVER_USERNAME="witcomm"
JUMP_SERVER_IP="www.opensource5g.org"
JUMP_SERVER_PORT=
# Trex server configuration.
TREX_SERVER_NAME="trex"
TREX_SERVER_IP="www.opensource5g.org"
TREX_SERVER_ASYNC_PORT="4501"
TREX_SERVER_SYNC_PORT="4500"
TREX_SERVER_USERNAME="witcomm"
TREX_SERVER_SSH="${TREX_SERVER_NAME}"
TREX_SERVER_SSH_ROOT="${TREX_SERVER_NAME}"
# TREX_SERVER_SSH="${TREX_SERVER_USERNAME}"@"${TREX_SERVER_IP}"
#TREX_VERSION=v3.00
TREX_VERSION=latest
TREX_EXTRACTED=v3.04
# TREX_VERSION=v2.87
#TREX_VERSION=v2.37
TREX_SHA256SUM=290c1be468335a2de2e69f217b139c9b1198732e529bfd069348d05297548b8a
TREX_SERVER_DOWNLOAD_DIR="${TREX_WORKSPACE}"
TREX_SERVER_DIR="${TREX_SERVER_DOWNLOAD_DIR}"/"${TREX_EXTRACTED}"
# Trex client configuration.
TREX_CLIENT_NAME= # Warning: Optional - If you set the name, it must be configured on your ssh config.
TREX_CLIENT_IP=
TREX_CLIENT_USERNAME=
TREX_CLIENT_SSH="${TREX_CLIENT_NAME}"
# TREX_CLIENT_SSH="${TREX_CLIENT_USERNAME}"@"${TREX_CLIENT_IP}"
TREX_CLIENT_UPLOAD_DIR="${TREX_WORKSPACE}"
TREX_CLIENT_DIR="${TREX_CLIENT_UPLOAD_DIR}"/trex_client
TREX_CLIENT_LIB_DIR="${TREX_CLIENT_DIR}"/interactive
########################################################
######## DUT - Device Under Test Configuration #########
########################################################
DUT_NAME="upf"
DUT_IP="www.opensource5g.org"
DUT_USERNAME="witcomm"
DUT_UPLOAD_DIR="${DUT_UPF_WORKSPACE_STANDALONE}"/package
# Test local configuration.
DUT_CONFIG_DIR="${DUT_UPF_WORKSPACE_STANDALONE}"/tests/trex/config
DUT_TRAFFIC_DIR="${DUT_UPF_WORKSPACE_STANDALONE}"/tests/trex/traffic
DUT_TEST_CASES_DIR="${DUT_UPF_WORKSPACE_STANDALONE}"/tests/trex/test_cases
DUT_SCRIPTS="${DUT_UPF_WORKSPACE_STANDALONE}"/tests/scripts
DUT_DEPLOYMENT="${DUT_UPF_WORKSPACE_STANDALONE}"/tests/deployment
DUT_SERVER_UPLOAD_DIR="${DUT_UPF_WORKSPACE_STANDALONE}"/tests/trex
DUT_PACKAGE="${DUT_UPF_WORKSPACE_STANDALONE}"/package
# Test remote configuration
TREX_CONFIG_DIR="${TREX_SERVER_DOWNLOAD_DIR}"/config
TREX_TRAFFIC_DIR="${TREX_SERVER_DOWNLOAD_DIR}"/traffic
TREX_TEST_CASES_DIR="${TREX_SERVER_DOWNLOAD_DIR}"/test_cases
# SSH port forwarding configuration
DUT_HTTP_SSH_PORT_FORWARDING="1234"
DUT_TREX_SYNC_SSH_PORT_FORWARDING="4501"
DUT_TREX_ASYNC_SSH_PORT_FORWARDING="4500"
API_HTTP_PORT="80"
# Programs name
API_PROGRAM_NAME=api
PYTHONPATH=/workspaces/tests/trex/trex_client/interactive/
#!/bin/bash
# ==============================================
# Author: Franck MESSAOUDI
# email: franck.messaoudi@openairinterface.org
#
# Script for testbed.
# Run the server and client on remote servers.
# Run control plane on dut.
#
# Packages required: tmux
#=============================================
# configure_layout() {
# tmux split-window -t "$1:$2.$3" "$4"
# }
# resize_panel() {
# tmux resize-pane -t "$1:$2.$3" "$4" "$5"
# }
send_keys_trex() {
#---------------------------------------------------------#
# PANEL 0 #
#---------------------------------------------------------#
tmux send-keys -t "$session_name:0.0" "ssh ${TREX_SERVER_SSH}" C-m
tmux send-keys -t "$session_name:0.0" "cd ${TREX_SERVER_DIR}" C-m
tmux send-keys -t "$session_name:0.0" "./t-rex-64 -i --cfg ${TREX_CONFIG_DIR}/trex-dut-ip-config.yaml" C-m
}
send_keys_upf_logs() {
#---------------------------------------------------------#
# PANEL 0 #
#---------------------------------------------------------#
tmux send-keys -t "$session_name:1.0" "ssh ${DUT_NAME}" C-m
tmux send-keys -t "$session_name:1.0" "cd ${XDP_DUMP}" C-m
# tmux send-keys -t "$session_name:1.0" "sudo ./xdpdump -i enp5s0f0 --use-pcap -w "$1"/capture_"$2"_enp5s0f0.pcap" C-m
#---------------------------------------------------------#
# PANEL 1 #
#---------------------------------------------------------#
tmux send-keys -t "$session_name:1.1" "ssh ${DUT_NAME}" C-m
tmux send-keys -t "$session_name:1.1" "cd ${XDP_DUMP}" C-m
# tmux send-keys -t "$session_name:1.1" "sudo ./xdpdump -i enp5s0f1 -w "$1"/capture_"$2"_enp5s0f1.pcap" C-m
#---------------------------------------------------------#
# PANEL 2 #
#---------------------------------------------------------#
tmux send-keys -t "$session_name:1.2" "ssh ${DUT_NAME}" C-m
tmux send-keys -t "$session_name:1.2" "cd ${XDP_MONITOR}" C-m
tmux send-keys -t "$session_name:1.2" "sudo ./xdp-monitor -e >> "$1"/xdp-monitor_"$2".log" C-m
#---------------------------------------------------------#
# PANEL 3 #
#---------------------------------------------------------#
tmux send-keys -t "$session_name:1.3" "ssh ${DUT_NAME}" C-m
tmux send-keys -t "$session_name:1.3" "mpstat -P ALL 3 >> "$1"/cpu-usage_"$2".log" C-m
#---------------------------------------------------------#
# PANEL 4 #
#---------------------------------------------------------#
tmux send-keys -t "$session_name:1.4" "sleep 7; ssh ${TREX_SERVER_NAME}" C-m
tmux send-keys -t "$session_name:1.4" "cd ${TREX_TEST_CASES_DIR}; export PYTHONPATH='../trex_client/interactive/'" C-m
tmux send-keys -t "$session_name:1.4" "python3 run_gtp.py -m 100% -p mesfa -f gtp -q "$3" -d "$4" -s "$5"" C-m
}
create_window_trex() {
tmux rename-window -t 0 'TRex'
# tmux split-window -t $session_name:0.0 -h
send_keys_trex
}
create_window_upf_logs() {
tmux new-window -d -t "$session_name" -n 'UPF_logs'
tmux split-window -t $session_name:1.0 -h
tmux split-window -t $session_name:1.1 -h
tmux split-window -t $session_name:1.1 -v
tmux split-window -t $session_name:1.3 -v
send_keys_upf_logs "$1" "$2" "$3" "$4" "$5"
}
attach() {
echo "Attaching on session ${session_name}..."
tmux select-pane -t "$session_name:0.0"
tmux -2 attach-session -t "$session_name"
}
force_kill() {
echo "Killing session ${session_name}..."
tmux kill-session -t "$session_name" 2>/dev/null
}
stop() {
echo "Stopping session ${session_name}..."
}
main() {
set -o errexit
set -o pipefail
set -o nounset
# set -x
local -r dirname="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
local -r filename="${dirname}/$(basename "${BASH_SOURCE[0]}")"
local -r session_name="china"
source "${dirname}/../env.sh"
XDP_TOOLS="${UPF_WORKSPACE}/xdp-tools"
XDP_DUMP="${XDP_TOOLS}/xdp-dump"
XDP_MONITOR="${XDP_TOOLS}/xdp-monitor"
SCRIPTS="${DUT_UPF_WORKSPACE_STANDALONE}/tests/scripts"
unset TMUX
tmux -2 new-session -d -s "$session_name"
create_window_trex
create_window_upf_logs "$1" "$2" "$3" "$4" "$5"
attach
stop
force_kill
}
main "$@"
#!/bin/bash
# ==============================================
# Author: Franck MESSAOUDI
# email: franck.messaoudi@openairinterface.org
#
# Script for testbed.
# Run the server and client on remote servers.
# Run control plane on dut.
#
# Packages required: tmux
#=============================================
# configure_layout() {
# tmux split-window -t "$1:$2.$3" "$4"
# }
# resize_panel() {
# tmux resize-pane -t "$1:$2.$3" "$4" "$5"
# }
send_keys_trex() {
#---------------------------------------------------------#
# PANEL 0 #
#---------------------------------------------------------#
tmux send-keys -t "$session_name:0.0" "ssh ${TREX_SERVER_SSH} -p 22110" C-m
tmux send-keys -t "$session_name:0.0" "cd ${TREX_SERVER_DIR}" C-m
tmux send-keys -t "$session_name:0.0" "sudo ./t-rex-64 -i --cfg ${TREX_CONFIG_DIR}/trex-dut-ip-config.yaml" C-m
}
send_keys_upf_logs() {
#---------------------------------------------------------#
# PANEL 0 #
#---------------------------------------------------------#
tmux send-keys -t "$session_name:1.0" "ssh ${DUT_NAME} -p 11227" C-m
tmux send-keys -t "$session_name:1.0" "cd ${XDP_DUMP}" C-m
# tmux send-keys -t "$session_name:1.0" "sudo ./xdpdump -i enp5s0f1 --use-pcap -w "$1"___capture_enp5s0f1.pcap" C-m
#---------------------------------------------------------#
# PANEL 1 #
#---------------------------------------------------------#
tmux send-keys -t "$session_name:1.1" "ssh ${DUT_NAME} -p 11227" C-m
tmux send-keys -t "$session_name:1.1" "cd ${XDP_DUMP}" C-m
# tmux send-keys -t "$session_name:1.1" "sudo ./xdpdump -i enp5s0f0 -w "$1"___capture_enp5s0f0.pcap" C-m
#---------------------------------------------------------#
# PANEL 2 #
#---------------------------------------------------------#
tmux send-keys -t "$session_name:1.2" "ssh ${DUT_NAME} -p 11227" C-m
tmux send-keys -t "$session_name:1.2" "cd ${XDP_MONITOR}" C-m
tmux send-keys -t "$session_name:1.2" "sudo ./xdp-monitor -e >> "$1"___xdp-monitor.log" C-m
#---------------------------------------------------------#
# PANEL 3 #
#---------------------------------------------------------#
tmux send-keys -t "$session_name:1.3" "ssh ${DUT_NAME} -p 11227" C-m
tmux send-keys -t "$session_name:1.3" "mpstat -P ALL 3 >> "$1"___cpu-usage.log" C-m
#---------------------------------------------------------#
# PANEL 4 #
#---------------------------------------------------------#
tmux send-keys -t "$session_name:1.4" "sleep 7; ssh ${TREX_SERVER_NAME} -p 22110" C-m
tmux send-keys -t "$session_name:1.4" "cd ${TREX_TEST_CASES_DIR}; export PYTHONPATH='../trex_client/interactive/'" C-m
tmux send-keys -t "$session_name:1.4" "python3 run_udp.py -m 100% -p 1 -f udp -q "$3" -d "$4" -s "$5"" C-m
}
create_window_trex() {
tmux rename-window -t 0 'TRex'
# tmux split-window -t $session_name:0.0 -h
send_keys_trex
}
create_window_upf_logs() {
tmux new-window -d -t "$session_name" -n 'UPF_logs'
tmux split-window -t $session_name:1.0 -v
tmux split-window -t $session_name:1.0 -h
tmux split-window -t $session_name:1.1 -h
tmux split-window -t $session_name:1.3 -h
send_keys_upf_logs "$1" "$2" "$3" "$4" "$5"
}
attach() {
echo "Attaching on session ${session_name}..."
tmux select-pane -t "$session_name:0.0"
tmux -2 attach-session -t "$session_name"
}
force_kill() {
echo "Killing session ${session_name}..."
tmux kill-session -t "$session_name" 2>/dev/null
}
stop() {
echo "Stopping session ${session_name}..."
}
main() {
set -o errexit
set -o pipefail
set -o nounset
# set -x
local -r dirname="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
local -r filename="${dirname}/$(basename "${BASH_SOURCE[0]}")"
local -r session_name="upf_performance"
local -r passwd=1
source "${dirname}/../env.sh"
XDP_TOOLS="${UPF_WORKSPACE}/xdp-tools"
XDP_DUMP="${XDP_TOOLS}/xdp-dump"
XDP_MONITOR="${XDP_TOOLS}/xdp-monitor"
SCRIPTS="${DUT_UPF_WORKSPACE_STANDALONE}/tests/scripts"
unset TMUX
tmux -2 new-session -d -s "$session_name"
create_window_trex
create_window_upf_logs "$1" "$2" "$3" "$4" "$5"
attach
stop
force_kill
}
main "$@"
#!/bin/bash
transfer_files(){
local rx_queues=$1
scp $1 $2
# Check if the scp was successful
if [ $? -eq 0 ]; then
echo "Files transferred successfully."
else
echo "Error transferring files."
fi
}
remove_files(){
rm -f $1/*
}
main() {
set -o errexit
set -o pipefail
set -o nounset
local -r dirname="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
local -r filename="${dirname}/$(basename "${BASH_SOURCE[0]}")"
local -r session_name="china"
source "${dirname}/../env.sh"
TEST_DURATION=30 # Duration of each running test (seconds)
TEST_ITERATIONS=1 # Number of repetitions (#)
MAX_QUEUES=12
QUEUE_SIZE=1
PKT_SMALLEST_SIZE=64
PKT_BIGEST_SIZE=1460
PKT_STEP=50
# DESTINATION_DIR="cristal:/home/franck/workspace/results-china/${packet_size}Bytes/tx_rx_queue_${QUEUE_SIZE}"
SCRIPTS="${DUT_UPF_WORKSPACE_STANDALONE}/tests/scripts"
unset TMUX
tmux kill-session -t china 2>/dev/null || true
for ((packet_size=PKT_SMALLEST_SIZE; packet_size<=PKT_BIGEST_SIZE; packet_size+=PKT_STEP)); do
for queues_size in $(seq 1 $MAX_QUEUES); do
QUEUE_SIZE=$queues_size
SOURCE_DIR="${TREX_WORKSPACE}/results-china/gtp/${packet_size}Bytes/tx_rx_queue_${QUEUE_SIZE}"
SOURCE_DIR2="${UPF_WORKSPACE}/results-china/udp/${packet_size}Bytes/tx_rx_queue_${QUEUE_SIZE}"
echo "Set RX Queues to $QUEUE_SIZE"
sudo ethtool -L enp5s0f0 combined "$QUEUE_SIZE"
sudo ethtool -L enp5s0f1 combined "$QUEUE_SIZE"
tmux kill-session -t china 2>/dev/null || true
echo "Return DPDK used interfaces:"
ssh trex "cd \"${TREX_SERVER_DIR}\" && ./dpdk_setup_ports.py -L"
for i in $(seq 1 $TEST_ITERATIONS); do
echo "Packet Size: $packet_size, RX Queue: $QUEUE_SIZE, Test: $i"
echo "=========================================================="
sleep 2
# Run the test script in the background
"${SCRIPTS}/china_start_tests_gtp.sh" "$SOURCE_DIR" "$i" "$QUEUE_SIZE" "$TEST_DURATION" "$packet_size" "$SOURCE_DIR2" > output.log 2>&1 &
sleep $((TEST_DURATION + 20))
echo "KILL SESSION ..."
tmux kill-session -t china 2>/dev/null || true
wait
# Ensure the tmux session is really killed
if tmux has-session -t china 2>/dev/null; then
echo "Tmux session still exists, killing again..."
tmux kill-session -t china 2>/dev/null
fi
echo ""
echo ""
done
# DESTINATION_DIR="cristal:/home/franck/workspace/results-china/${packet_size}Bytes/tx_rx_queue_${QUEUE_SIZE}"
# transfer_files $SOURCE_DIR $DESTINATION_DIR
# delete_files $SOURCE_DIR
done
if [ "$packet_size" -eq 64 ]; then
packet_size=50
elif [ "$packet_size" -eq 1450 ]; then
PKT_STEP=10
fi
done
}
main "$@"
#!/bin/bash
remove_files(){
rm -f $1/*
}
main() {
set -o errexit
set -o pipefail
set -o nounset
local -r dirname="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
local -r filename="${dirname}/$(basename "${BASH_SOURCE[0]}")"
local -r session_name="upf_performance"
source "${dirname}/../env.sh"
TEST_DURATION=120 # Duration of each running test (seconds)
TEST_ITERATIONS=1 # Number of repetitions (#)
MAX_QUEUES=24
PKT_SMALLEST_SIZE=64
PKT_BIGEST_SIZE=64
PKT_STEP=50
# Flat saving directory for results
RESULT_DIR="${UPF_WORKSPACE}/new-results"
SCRIPTS="${DUT_UPF_WORKSPACE_STANDALONE}/tests/scripts"
unset TMUX
tmux kill-session -t upf_performance 2>/dev/null || true
for ((packet_size=$PKT_SMALLEST_SIZE; packet_size<=$PKT_BIGEST_SIZE; packet_size+=$PKT_STEP)); do
echo "Packet Size: $packet_size"
for queues_size in $(seq $MAX_QUEUES -1 1); do
QUEUE_SIZE=$queues_size
echo "Set RX Queues to $QUEUE_SIZE"
sudo ethtool -L enp1s0f0np0 combined "$QUEUE_SIZE"
sudo ethtool -L enp1s0f1np1 combined "$QUEUE_SIZE"
for i in $(seq 1 $TEST_ITERATIONS); do
echo "Packet Size: $packet_size, RX Queue: $QUEUE_SIZE, Test: $i, Duration: $TEST_DURATION"
echo "================================================="
echo ""
sleep 2
# Create a unique filename based on packet_size, QUEUE_SIZE, iteration, and timestamp
#TIMESTAMP=$(date +%Y%m%d_%H%M%S)
#OUTPUT_PREFIX="${RESULT_DIR}/UDP___TestIteration_${i}___PacketSize_${packet_size}Bytes___QueueSize_${QUEUE_SIZE}___TimeStamp_${TIMESTAMP}"
OUTPUT_PREFIX="${RESULT_DIR}/UDP___TestIteration_${i}___PacketSize_${packet_size}Bytes___QueueSize_${QUEUE_SIZE}"
# Pass the file paths to the child script
"${SCRIPTS}/china_start_tests_udp.sh" "$OUTPUT_PREFIX" "$i" "$QUEUE_SIZE" "$TEST_DURATION" "$packet_size" > "${OUTPUT_PREFIX}_output.log" 2>&1
# "${SCRIPTS}/china_start_tests_udp.sh" "$OUTPUT_PREFIX" "$i" "$QUEUE_SIZE" "$TEST_DURATION" "$packet_size" > "${OUTPUT_PREFIX}_output.log" 2>&1 &
sleep $((TEST_DURATION + 20))
echo "KILL SESSION ..."
tmux kill-session -t upf_performance 2>/dev/null || true
wait
# Ensure the tmux session is really killed
if tmux has-session -t upf_performance 2>/dev/null; then
echo "Tmux session still exists, killing again..."
tmux kill-session -t upf_performance 2>/dev/null
fi
echo ""
echo ""
done
done
if [ "$packet_size" -eq 64 ]; then
packet_size=50
elif [ "$packet_size" -eq 1450 ]; then
PKT_STEP=10
fi
done
}
main "$@"
#!/bin/sh
tmux kill-session -t test
sudo ip link set dev enp5s0f0 xdp off
sudo ip link set dev enp5s0f1 xdp off
sudo ethtool -s enp5s0f0 speed 10000 duplex full autoneg off
sudo ethtool -s enp5s0f1 speed 10000 duplex full autoneg off
sudo su
sudo echo 1 > /sys/kernel/debug/tracing/tracing_on
cat /sys/kernel/debug/tracing/tracing_on
exit
\ No newline at end of file
#!/usr/bin/env bash
#
# Copy trex configuration.
main() {
set -o errexit
set -o pipefail
set -o nounset
local -r dirname="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "${dirname}"/../env.sh
scp -r "${DUT_CONFIG_DIR}" "${TREX_SERVER_SSH}":"${TREX_SERVER_DOWNLOAD_DIR}"
scp -r "${DUT_TRAFFIC_DIR}" "${TREX_SERVER_SSH}":"${TREX_SERVER_DOWNLOAD_DIR}"
scp -r "${DUT_TEST_CASES_DIR}" "${TREX_SERVER_SSH}":"${TREX_SERVER_DOWNLOAD_DIR}"
exit 0
}
main "$@"
\ No newline at end of file
# Install t-rex.
main() {
echo "Trex Install ...!"
set -o errexit
set -o pipefail
set -o nounset
#set -x
local -r dirname="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
local -r download_dir="${1:-/tmp}"
# local -r trex_version="${2:-v3.00}"
local -r trex_version="${2:-latest}"
local -r trex_client_version="${3:-v3.04}"
local -r trex_extracted="${4:-v3.04}"
#local -r trex_version="${2:-v2.87}"
# local -r trex_shasum="${3:-290c1be468335a2de2e69f217b139c9b1198732e529bfd069348d05297548b8a}"
# local -r shasum=$(cat "${download_dir}"/"${trex_version}".tar.gz | sha256sum | awk '{print $1}')
local -r trex_dir="${download_dir}"/"${trex_version}"
local -r trex_client_dir="${download_dir}"/trex_client
# echo
# echo "Installation folder: "${download_dir}""
# echo "Installation version: "${trex_version}""
# echo "Installation sha256sum: "${trex_shasum}""
# echo
mkdir -p "${download_dir}"
# [ Check if trex not exist OR
# Check if trex has different checksum ] AND
# [ Check if the installation directoy not exist ] .
if [ ! -f "${download_dir}"/"${trex_version}" ] \
|| [ "${trex_shasum}" != "${shasum}" ] \
&& [ ! -d "${trex_dir}" ]; then
rm -f "${download_dir}"/"${trex_version}"
cd "${download_dir}"
wget --no-cache --no-check-certificate https://trex-tgn.cisco.com/trex/release/"${trex_version}"
tar -xzvf "${trex_version}"
echo "franck..."
tar -xzvf "${trex_extracted}"/trex_client_"${trex_client_version}".tar.gz
rm "${trex_version}"
fi
# Check if trex client directoty not exists AND tar.gz exists
if [ ! -d "${trex_client_dir}" ] && [ -f "${trex_dir}"/trex_client_"${trex_client_version}".tar.gz ]; then
echo "Installing the trex client..."
mkdir -p "${trex_client_dir}"
# trex_client must exist. Do not untar inside the trex_client_dir in order to avoid
# create two trex_client nested folder.
tar -xzvf "${trex_dir}"/trex_client_"${trex_client_version}" -C "${download_dir}"
echo "Done!"
fi
echo "The t-rex installation was successful!"
exit 0
}
main "$@"
#!/usr/bin/env bash
#
# Install the t-rex on server.
RED="\e[31m"
GREEN="\e[32m"
ENDCOLOR="\e[0m"
server_config(){
echo
echo "Installing trex on "${TREX_SERVER_IP}""
echo
echo -e "${GREEN}!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo
echo "Trex Has the following configuration :"
echo
echo " Trex Management IP -------------: "${TREX_SERVER_IP}""
echo " Trex Hostname ------------------: "${TREX_SERVER_NAME}""
echo " Trex Username ------------------: "${TREX_SERVER_USERNAME}""
echo " Trex App Version ---------------: "${TREX_VERSION}""
echo " Trex Install Dir ---------------: "${TREX_SERVER_DOWNLOAD_DIR}"/"${TREX_VERSION}""
echo " Trex sha256sum -----------------: "${TREX_SHA256SUM}""
echo
echo -e "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!${ENDCOLOR}"
echo
}
main() {
set -o errexit
set -o pipefail
set -o nounset
# set -x
local -r dirname="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "${dirname}"/../env.sh
server_config
# Execute local script (install_trex) on the server.
echo "SSH to Trex ..."
ssh "${TREX_SERVER_SSH}" "bash -s" -- "${TREX_SERVER_DOWNLOAD_DIR}" "${TREX_VERSION}" <"${dirname}"/install_trex.sh
}
main "$@"
\ No newline at end of file
Attaching on session china...
[exited]
Stopping session china...
Killing session china...
#!/usr/bin/env bash
#
# Run the t-rex on server.
main() {
set -o errexit
set -o pipefail
set -o nounset
local -r dirname="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
local -r trex_extracted="${1:-v3.04}"
source "${dirname}"/../env.sh
echo
echo "Run t-rex server on "${TREX_SERVER_IP}"."
echo
# https://superuser.com/questions/1138707/ssh-makes-all-typed-passwords-visible-when-command-is-provided-as-an-argument-to
ssh -t "${TREX_SERVER_SSH}" \
"cd ${TREX_SERVER_DOWNLOAD_DIR}/${trex_extracted}
sudo ./t-rex-64 -i --cfg ${TREX_CONFIG_DIR}/trex-dut-ip-config.yaml"
exit 0
}
main "$@"
# sudo ./t-rex-64 -c6 -v 8 -i --cfg ${TREX_CONFIG_DIR}/platform_profile_dpdk.yaml"
#!/bin/bash
# ==============================================
# Author: Franck MESSAOUDI
# email: franck.messaoudi@openairinterface.org
#
# Script for testbed.
# Run the server and client on remote servers.
# Run control plane on dut.
#
# Packages required: tmux
#=============================================
#Create remote session with panes
configure_layout(){
tmux split-window -t $1:$2.$3 $4
}
resize_panel(){
tmux resize-pane -t $1:$2.$3 $4 $5
}
send_keys_upf(){
#---------------------------------------------------------#
# PANEL 0 #
#---------------------------------------------------------#
tmux send-keys -t $session_name:0.0 "sleep 20; ssh "${DUT_NAME}"" C-m
tmux send-keys -t $session_name:0.0 "cd "${DUT_UPF_WORKSPACE_STANDALONE}"" C-m
tmux send-keys -t $session_name:0.0 "ip link set dev "${UPF_N3_INTERFACE}" xdp off; ip link set dev "${UPF_N6_INTERFACE}" xdp off" C-m
#tmux send-keys -t $session_name:0.0 "make clean && make setup && make install" C-m
tmux send-keys -t $session_name:0.0 "upf -o -c etc/config.yaml" C-m
#---------------------------------------------------------#
# PANEL 1 #
#---------------------------------------------------------#
tmux send-keys -t $session_name:0.1 "ssh "${DUT_NAME}"" C-m
#tmux send-keys -t $session_name:0.1 "sleep 240" C-m
tmux send-keys -t $session_name:0.1 "bpftool prog tracelog" C-m
#---------------------------------------------------------#
# PANEL 2 #
#---------------------------------------------------------#
tmux send-keys -t $session_name:0.2 "ssh "${DUT_NAME}"" C-m
tmux send-keys -t $session_name:0.2 "cd "${DUT_CN_WORKSPACE_STANDALONE}"" C-m
tmux send-keys -t $session_name:0.2 "docker-compose -f docker-compose/"${CN_DOCKER_COMPOSE_FILE}" down -t0" C-m
tmux send-keys -t $session_name:0.2 "docker-compose -f docker-compose/"${CN_DOCKER_COMPOSE_FILE}" up -d" C-m
tmux send-keys -t $session_name:0.2 "watch docker ps" C-m
#---------------------------------------------------------#
# PANEL 3 #
#---------------------------------------------------------#
tmux send-keys -t $session_name:0.3 "ssh "${DUT_NAME}"" C-m
tmux send-keys -t $session_name:0.3 "echo "1" > /proc/sys/net/ipv4/ip_forward" C-m
#tmux send-keys -t $session_name:0.3 "apt-get install -y sysstat" C-m
#tmux send-keys -t $session_name:0.3 "sleep 60" C-m
tmux send-keys -t $session_name:0.3 "mpstat -P ALL 3" C-m
}
remove_trex(){
if ssh trex [ -d "/tmp/trex_client" ]
then
ssh trex rm -rf /tmp/trex_client
fi
if ssh trex [ -d "/tmp/latests" ]
then
ssh trex rm -rf /tmp/latest
fi
}
send_keys_trex(){
#---------------------------------------------------------#
# PANEL 0 #
#---------------------------------------------------------#
tmux send-keys -t $session_name:1.0 "sleep 55; ssh "${TREX_SERVER_NAME}"" C-m
#tmux send-keys -t $session_name:1.0 "echo "1" > /proc/sys/net/ipv4/ip_forward" C-m
#tmux send-keys -t $session_name:1.0 "echo off > /sys/devices/system/cpu/smt/control" C-m
tmux send-keys -t $session_name:1.0 "cd "${TREX_SERVER_DIR}"; ./trex-console --port "${DUT_TREX_SYNC_SSH_PORT_FORWARDING}" --async_port "${DUT_TREX_ASYNC_SSH_PORT_FORWARDING}"" C-m
tmux send-keys -t $session_name:1.0 "start -f "${TREX_TRAFFIC_DIR}"/udp_1pkt_tuple_gen.py -m 1mpps -p 1; portattr -a --prom on; tui" C-m
# tmux send-keys -t $session_name:1.0 "start -f "${TREX_TRAFFIC_DIR}"/gtp_1pkt_simple.py -m 100kpps -p 0; \
# portattr -a --prom on; tui" C-m
#---------------------------------------------------------#
# PANEL 1 #
#---------------------------------------------------------#
tmux send-keys -t $session_name:1.1 "sleep 30; "${dirname}"/install_trex_remote.sh" C-m
tmux send-keys -t $session_name:1.1 ""${dirname}"/deploy_trex_config.sh" C-m
tmux send-keys -t $session_name:1.1 ""${dirname}"/run_trex_server.sh" C-m
#tmux send-keys -t $session_name:1.1 "ssh "${TREX_SERVER_NAME}"" C-m
}
create_window_upf(){
tmux rename-window -t 0 'UPF'
configure_layout $session_name 0 0 -h
configure_layout $session_name 0 1 -v
configure_layout $session_name 0 0 -v
#resize_panel $session_name 0 0 -L 10
send_keys_upf
}
create_window_trex() {
tmux new-window -d -t $session_name -n 'Trex'
configure_layout $session_name 1 0 -h
resize_panel $session_name 1 0 -R 20
send_keys_trex
}
attach() {
echo "Attaching on session "${session_name}"..."
tmux select-pane -t $session_name:0.0
tmux -2 attach-session -t $session_name
}
stop() {
echo "Stopping on session "${session_name}"..."
}
force_kill() {
echo "Killing on session "${session_name}"..."
sleep 2
tmux kill-session -t $session_name 2>/dev/null
}
main() {
# set -o errexit
set -o pipefail
set -o nounset
# set -x
local -r dirname="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
local -r filename="${dirname}/$(basename "${BASH_SOURCE[0]}")"
local -r session_name="test"
source "${dirname}"/../env.sh
# echo -n "Enter the server admin password:"
# echo
# read -s SERVER_PASSWORD
unset TMUX
echo "Creating test session: "${session_name}"..."
tmux kill-session -t $session_name -n testbed 2>/dev/null
tmux -2 new-session -d -s $session_name
create_window_upf
#remove_trex
create_window_trex
attach
stop
force_kill
}
main "$@"
#!/bin/bash
output_file=$1
interval=$2
iterations=$3
# Initialize the output file
echo "Top output every $interval seconds:" > "$output_file"
# Loop to collect top output at regular intervals
for ((i = 1; i <= iterations; i++))
do
echo -e "\nIteration $i:" >> "$output_file"
top -b -n 1 >> "$output_file"
sleep $interval
done
\ No newline at end of file
# !/bin/sh
N3_UPF_IP="192.168.101.2"
N6_UPF_IP="192.168.102.2"
N3_TREX_IP="192.168.101.3"
N6_TREX_IP="192.168.102.3"
N3_BRIDGE_MAC="52:54:00:e6:c5:a2"
N6_BRIDGE_MAC="52:54:00:a2:5c:ac"
#---------------------------------------------------------------------------#
ip2dec2hex () {
local a b c d __ret_val ip=$@
IFS=. read -r a b c d <<< "$ip"
__ret_val="$((a * 256 ** 3 + b * 256 ** 2 + c * 256 + d))"
echo "obase=16; $__ret_val" | bc
}
#---------------------------------------------------------------------------#
iphex2str(){
local __ret_val len
local val=$@ str=" " zero="0"
len=${#val}
if [ $len -eq 8 ]
then
__ret_val="${val:0:2}$str${val:2:2}$str${val:4:2}$str${val:6:2}"
elif [ $len -eq 7 ]
then
__ret_val="$zero${val:0:1}$str${val:1:2}$str${val:3:2}$str${val:5:2}"
else
echo The value is not correct!
fi
echo $__ret_val
}
#---------------------------------------------------------------------------#
mac2hex() {
local __ret_val val=$@
__ret_val=${val//:/" "}
echo $__ret_val
}
#---------------------------------------------------------------------------#
# getMapId(){
# local id
# id=$(sudo bpftool map list | awk '{if($4 == "m_arp_table") print $1}'| cut -f1 -d":")
# echo $id
# }
getMapId() {
local ids=()
# Use map command to get a list of map IDs and store them in the array
while IFS= read -r id; do
ids+=("$id")
done < <(sudo bpftool map list | awk '{if($4 == "m_arp_table") print $1}' | cut -f1 -d":")
# Return the array
echo "${ids[@]}"
}
#---------------------------------------------------------------------------#
#---------------------------------------------------------------------------#
#---------------------------------------------------------------------------#
main(){
set -o errexit
set -o pipefail
#set -o nounset
# IP Conversions:
N3_UPF_IP=$( iphex2str $(ip2dec2hex $N3_UPF_IP) )
N6_UPF_IP=$( iphex2str $(ip2dec2hex $N6_UPF_IP) )
N3_TREX_IP=$( iphex2str $(ip2dec2hex $N3_TREX_IP) )
N6_TREX_IP=$( iphex2str $(ip2dec2hex $N6_TREX_IP) )
# MAC Conversions:
N3_BRIDGE_MAC=$( mac2hex $N3_BRIDGE_MAC )
N6_BRIDGE_MAC=$( mac2hex $N6_BRIDGE_MAC )
echo "N3_UPF_IP = $N3_UPF_IP"
echo "N6_UPF_IP = $N6_UPF_IP"
echo "N3_BRIDGE_MAC = $N3_BRIDGE_MAC"
echo "N6_BRIDGE_MAC = $N6_BRIDGE_MAC"
# Call the function to get an array of map IDs
mapIds=($(getMapId))
# Check if the array is not empty
if [ "${#mapIds[@]}" -gt 0 ]; then
echo "ARP Table Map IDs: ${mapIds[@]}"
# Iterate through the array and use the values
for id in "${mapIds[@]}"; do
echo " - $id"
# Update mac map:
sudo bpftool map update id $id key hex $N3_UPF_IP value hex $N3_BRIDGE_MAC 00 00 $N3_TREX_IP
sudo bpftool map update id $id key hex $N6_UPF_IP value hex $N6_BRIDGE_MAC 00 00 $N6_TREX_IP
sudo bpftool map dump id $id
done
else
echo "No map IDs found."
fi
exit 0
}
main
\ No newline at end of file
# ### Config file generated by dpdk_setup_ports.py ###
# - port_limit: 2
# version: 2
# interfaces: ['05:00.0', '05:00.1']
# port_bandwidth_gb: 10
# rx_desc: 4096
# tx_desc: 4096
# #limit_memory: 32768
# c: 5
# port_info:
# - ip: 192.168.101.3
# dest_mac: '50:7c:6f:5b:34:b0'
# #default_gw: 192.168.101.2
# - ip: 192.168.102.3
# dest_mac: '50:7c:6f:5b:34:b1'
# #default_gw: 192.168.102.2
# platform:
# master_thread_id: 0
# latency_thread_id: 1
# dual_if:
# - socket: 0
# threads: [2,3,4,5,6]
# - socket: 1
# threads: [7,8,9,10,11]
# rx:
# - name: "n3"
# num: 6
# - name: "n6"
# num: 6
\ No newline at end of file
### Config file generated by dpdk_setup_ports.py ###
- version: 2
port_limit: 2
interfaces: ['01:00.0', '01:00.1']
port_info:
- dest_mac: 6c:b3:11:83:00:f6 # 192.168.10.10 (upf n3)
src_mac: 6c:b3:11:29:5a:86 # 192.168.10.100 (trex n3)
- dest_mac: 6c:b3:11:83:00:f7 # 192.168.20.10 (upf n6)
src_mac: 6c:b3:11:29:5a:87 # 192.168.20.100 (trex n6)
c: 14
platform:
master_thread_id: 0
latency_thread_id: 1
dual_if:
- socket: 0
threads: [2,3,4,5,6,7,8,9,10,11,12,13,14,15]
define: &trex_app
version: &version v3.00
sha256sum: 290c1be468335a2de2e69f217b139c9b1198732e529bfd069348d05297548b8a
download_path: &download_path /tmp/
## Trex Server Configuration ##
trex_server:
hostname: dn
username: ubuntu
ip: 172.21.19.56
async_port: 4501
sync_port: 4500
trex_server_app:
<<: *trex_app
#path: !join [*download_path, *version]
## Trex Client Configuration ##
trex_client:
hostname:
username:
ip:
client_ssh:
trex_client_app:
<<: *trex_app
relative_path: trex_client/
relative_lib_path: interactive/
import time
import uuid
from datetime import datetime
from threading import Thread, Event
import scapy.sendrecv
from scapy.contrib.gtp import GTP_U_Header, GTPPDUSessionContainer
from scapy.contrib.pfcp import IE_ApplyAction, IE_CreateFAR, IE_CreatePDR, IE_DestinationInterface, \
IE_FAR_Id, \
IE_ForwardingParameters, IE_FSEID, IE_NetworkInstance, IE_NodeId, IE_PDI, IE_PDR_Id, IE_Precedence, \
IE_RecoveryTimeStamp, IE_SourceInterface, IE_UE_IP_Address, IE_FTEID, IE_OuterHeaderCreation, \
IE_OuterHeaderRemoval, \
PFCP, \
PFCPAssociationSetupRequest, PFCPSessionEstablishmentRequest, \
PFCPSessionModificationRequest, \
IE_CPFunctionFeatures, PFCPSessionEstablishmentResponse, IE_CreatedPDR, IE_QFI, PFCPHeartbeatResponse, \
IE_SequenceNumber, PFCPHeartbeatRequest
from scapy.layers.inet import IP, UDP
from scapy.all import sniff
SMF_IP = "192.168.199.110"
UPF_IP_N3 = "192.168.10.10"
UPF_IP_N4 = "192.168.199.227"
UPF_IP_N6 = "192.168.20.10"
UE_IP = "192.168.10.100"
#UE_IP = "12.1.1.3"
gNB_IP = "192.168.10.100"
GOOGLE_DNS_IP = "8.8.8.8"
SEQ = 16770408
FTEID_UL = 0x00000001
FTEID_DL = 0x00000002
# UE_IP_UL = "12.1.1.2"
def seid():
#return uuid.uuid4().int & (1 << 64) - 1
return 1
def ie_fteid_set(fteid, ipv4):
return IE_FTEID(V4=1, TEID=fteid, ipv4=ipv4)
def ie_fteid():
return IE_FTEID(CH=1, V4=1)
def ie_fteid_ch(chid):
return IE_FTEID(CH=1, CHID=1, choose_id=chid, V4=1)
def outer_header_creation(fteid, ipv4):
return IE_OuterHeaderCreation(
GTPUUDPIPV4=1, TEID=fteid, ipv4=ipv4)
def create_pdr_ul(pdr_id, far_id, nwi, sdf_filter, source_iface, ip, sd):
return IE_CreatePDR(IE_list=[
IE_PDR_Id(id=pdr_id),
IE_Precedence(precedence=0),
IE_PDI(IE_list=[
IE_SourceInterface(interface=source_iface),
ie_fteid_ch(42),
IE_NetworkInstance(instance=nwi),
IE_UE_IP_Address(ipv4=ip, V4=1, SD=sd),
# IE_SDF_Filter(FD=1,
# flow_description=sdf_filter),
IE_QFI(QFI=8)
]),
IE_OuterHeaderRemoval(header="GTP-U/UDP/IPv4"),
IE_FAR_Id(id=far_id),
])
def create_pdr_dl(pdr_id, far_id, nwi, sdf_filter, source_iface, ip, sd):
return IE_CreatePDR(IE_list=[
IE_PDR_Id(id=pdr_id),
IE_Precedence(precedence=0),
IE_PDI(IE_list=[
IE_SourceInterface(interface=source_iface),
IE_NetworkInstance(instance=nwi),
# IE_SDF_Filter(FD=1, flow_description=sdf_filter),
IE_UE_IP_Address(ipv4=ip, V4=1, SD=sd)
]),
IE_FAR_Id(id=far_id)
])
def create_far_ul(far_id, nwi):
return IE_CreateFAR(IE_list=[
IE_FAR_Id(id=far_id),
IE_ApplyAction(FORW=1),
IE_ForwardingParameters(IE_list=[
# IE_DestinationInterface(interface="SGi-LAN/N6-LAN"),
IE_DestinationInterface(interface="Core"),
IE_NetworkInstance(instance=nwi),
])
])
def create_far_dl(far_id, nwi, fteid, ipv4):
return IE_CreateFAR(IE_list=[
IE_FAR_Id(id=far_id),
IE_ApplyAction(FORW=1),
IE_ForwardingParameters(IE_list=[
IE_DestinationInterface(interface="Access"),
IE_NetworkInstance(instance=nwi),
outer_header_creation(fteid, ipv4)
])
])
def session_establishment_ul(seid_):
return PFCPSessionEstablishmentRequest(IE_list=[
IE_NodeId(id_type="FQDN", id=SMF_ID),
IE_FSEID(seid=seid_, ipv4="192.168.100.1", v4=1),
create_pdr_ul(1, 1, "access.oai.org", "permit out ip from any to assigned", "Access", UE_IP, 0),
create_far_ul(1, "core.oai.org")
])
def session_modification_dl(seid_):
return PFCPSessionModificationRequest(IE_list=[
# IE_NodeId(id_type="FQDN", id=SMF_ID),
IE_FSEID(seid=seid_, ipv4="192.168.100.1", v4=1),
create_pdr_dl(2, 2, "core.oai.org", "permit out ip from any to assigned", "Core", UE_IP, 1),
create_far_dl(2, "access.oai.org", FTEID_DL, gNB_IP),
])
# def icmp_request_ul(fteid, dst ="8.8.8.8"):
# res = scapy.sendrecv.sr1(IP(src=f"{gNB_IP}", dst="192.168.101.2", flags=["DF"]) /
# UDP(sport=2152, dport=2152) / GTP_U_Header(teid=fteid) / GTPPDUSessionContainer(type=1,
# QFI=8) /
# IP(src=f"{UE_IP}", dst=dst, flags=["DF"]) / ICMP()/(b"1"*48)
# )
# print(res)
def association():
ts = int((datetime.now() - datetime(1900, 1, 1)).total_seconds())
return (PFCPAssociationSetupRequest(IE_list=[
IE_NodeId(id_type="FQDN", id=SMF_ID),
IE_RecoveryTimeStamp(timestamp=ts),
IE_CPFunctionFeatures(OVRL=1, LOAD=1)
]))
def send_receive_pfcp(msg, seid_=None, recv=True, seq=None):
global SEQ
seq = seq if seq else SEQ
pfcp = PFCP(version=1, seq=seq,
S=0 if seid_ is None else 1,
seid=0 if seid_ is None else seid_)
SEQ += 1
pkt = IP(src="192.168.100.1", dst="192.168.100.2", proto=17) / UDP(sport=8805, dport=8805) / pfcp / msg
# sr1 only returns first answered packet
if recv:
res = scapy.sendrecv.sr1(pkt)
print(res)
return res
else:
scapy.sendrecv.send(pkt)
class Sniffer(Thread):
def __init__(self, if_name, filter, heartbeat=True):
super().__init__()
self.if_name = if_name
self.filter = filter
self.heartbeat = heartbeat
self.stop = Event()
def run(self):
sniff(iface=self.if_name, filter=self.filter, prn=self.callback, store=0, stop_filter=self.should_stop)
def join(self, timeout=None):
self.stop.set()
super().join(timeout)
def callback(self, pkt):
print(f"Received packet: {pkt}")
try:
callback_resp = pkt[PFCPHeartbeatRequest]
seq_number = callback_resp[IE_SequenceNumber].number
send_receive_pfcp(PFCPHeartbeatResponse, recv=False, seq=seq_number)
except IndexError: # also traces other responses
pass
def should_stop(self, packet):
return self.stop.is_set()
def main():
#heartbeat_sniffer = Sniffer(if_name="demo-oai", filter="dst host 192.168.100.2 and udp port 8805")
#icmp_sniffer = Sniffer(if_name="cn5g-access", filter="dst host 192.168.72.1 and icmp")
# print("Starting heartbeat and ICMP sniffer in background")
#heartbeat_sniffer.start()
#icmp_sniffer.start()
print("Send PFCP association setup")
send_receive_pfcp(association())
s = seid()
print("Now sleep for 10 seconds while we answer heartbeats")
time.sleep(1)
print("Send PFCP session establishment")
res = send_receive_pfcp(session_establishment_ul(s), seid_=0)
session_resp = res[PFCPSessionEstablishmentResponse]
created_fteid = session_resp[IE_CreatedPDR][IE_FTEID].TEID
print(f"Created FTEID: {hex(created_fteid)}")
time.sleep(1)
print("Send PFCP session modification")
send_receive_pfcp(session_modification_dl(s), seid_=s)
time.sleep(1)
# TODO this hangs currently, because scapy does not find the return value. I really would like to verify here
# if there is a response
#icmp_request_ul(created_fteid, "192.168.73.135")
# icmp_request_ul(created_fteid, "8.8.8.8")
time.sleep(1)
if __name__ == "__main__":
main()
import json
import sys
hostname = "http://localhost:1234/"
dir = "test-sessions"
def add_basic_arp_rule():
return [{"ip": "10.0.0.0","mac": "a0:36:9f:23:ac:2c"}]
def create_arp_table(num, session, n_rules):
offset = (session - 1) * n_rules + num + 1
x = int(offset / 256)
y = offset % 256
ip = "10.1."+str(x)+"."+str(y)
return [{"ip":ip,"mac": "a0:36:9f:23:ac:2e"}]
def create_far_rule(num, session, n_rules):
farid = session * 100 + 1 + 2 * num
offset = (session - 1) * n_rules + num + 1
x = int(offset / 256)
y = offset % 256
ip = "10.1."+str(x)+"."+str(y)
far = [{"farId": farid,"forwardingParameters": {"outerHeaderCreation": {"outerHeaderCreationDescription": "OUTER_HEADER_CREATION_GTPU_UDP_IPV4","ipv4Address": ip,"portNumber": 1234},"destinationInterface": "INTERFACE_VALUE_ACCESS"}}]
farid += 1
far.extend([{"farId": farid, "forwardingParameters": {"outerHeaderCreation": {"outerHeaderCreationDescription": "OUTER_HEADER_CREATION_UDP_IPV4","ipv4Address": ip,"portNumber": 1234},"destinationInterface": "INTERFACE_VALUE_CORE"}}])
return far
def create_pdr_rule(num, session, n_rules):
pdrid = session * 100 + 1 + 2 * num
farid = pdrid
teid = pdrid
precedence = pdrid
offset = (session - 1) * n_rules + num + 1
x = int(offset / 256)
y = offset % 256
ip = "10.1."+str(x)+"."+str(y)
pdr = [{ "pdrId":pdrid,"farId":farid, "outerHeaderRemoval": "OUTER_HEADER_REMOVAL_UDP_IPV4", "pdi": {"teid":teid,"sourceInterface": "INTERFACE_VALUE_CORE","ueIPAddress":ip}, "precedence": precedence}]
pdrid += 1
farid += 1
teid += 1
precedence += 1
pdr.extend([{"pdrId":pdrid, "farId":farid, "outerHeaderRemoval": "OUTER_HEADER_REMOVAL_GTPU_UDP_IPV4","pdi": {"teid":teid,"sourceInterface": "INTERFACE_VALUE_ACCESS","ueIPAddress":ip}, "precedence": precedence}])
return pdr
def create_body(session_id, n_rules):
mydict = {"seid":session_id, "pdrs":[], "fars":[], "arpTable":[]}
for j in range(n_rules):
mydict["pdrs"].extend(create_pdr_rule(j, session_id, n_rules))
# Adding FAR rules
for j in range(n_rules):
mydict["fars"].extend(create_far_rule(j, session_id, n_rules))
mydict["arpTable"].extend(add_basic_arp_rule())
for j in range(n_rules):
mydict["arpTable"].extend(create_arp_table(j, session_id, n_rules))
return mydict
def create_session(session_id, n_rules):
filename = "session_"+str(session_id)+".json"
path = dir+"/"+filename
f = open(path, "w")
string = create_body(session_id, n_rules)
json.dump(string, f, indent = 6)
f.close()
def create_sessions(n_sessions, n_rules):
sessions_counter = 0
for i in range(1, int(n_sessions)+1):
create_session(i, int(n_rules))
def main(argv):
if len(sys.argv) != 3:
print("Usage: <N_SESSIONS> <N_RULES_PER_SESSION>")
sys.exit(2)
n_sessions = sys.argv[1]
n_rules = sys.argv[2]
print("Number of sessions:", n_sessions, "number of rules:", n_rules)
create_sessions(n_sessions, n_rules)
if __name__ == "__main__":
main(sys.argv)
#import stl_path
from trex_stl_lib.api import *
import time
import json
# simple packet creation
def create_pkt(src):
return STLPktBuilder(
pkt=Ether()/IP(src=src, dst="10.1.3.27") /
UDP(dport=1234)/Raw('x'*20)
)
def simple_burst():
# create client
c = STLClient()
# username/server can be changed those are the default
# username = common.get_current_user(),
# server = "localhost"
# STLClient(server = "my_server",username ="trex_client") for example
passed = True
try:
# turn this on for some information
# c.set_verbose("debug")
# create two streams
s1 = STLStream(packet=create_pkt("10.1.2.29"),
mode=STLTXCont())
s2 = STLStream(packet=create_pkt("10.1.2.30"),
mode=STLTXCont())
# connect to server
c.connect()
# prepare our ports (my machine has 0 <--> 1 with static route)
# Acquire port 0 for $USER
c.reset(ports=[0, 1])
# add both streams to ports
c.add_streams([s1, s2], ports=[0])
# clear the stats before injecting
c.clear_stats()
# set port 1 as promiscuous mode
c.set_port_attr(ports=[1], promiscuous=True)
# choose rate and start traffic for 10 seconds on 14 mpps
print("Running 14 Mpps on ports 0 for 10 seconds...")
c.start(ports=[0], mult="14mpps", duration=10)
# block until done
c.wait_on_traffic(ports=[0])
# read the stats after the test
stats = c.get_stats()
print(json.dumps(stats[0], indent=4,
separators=(',', ': '), sort_keys=True))
print(json.dumps(stats[1], indent=4,
separators=(',', ': '), sort_keys=True))
lost_a = stats[0]["opackets"] - stats[1]["ipackets"]
lost_b = stats[1]["opackets"] - stats[0]["ipackets"]
print("\npackets lost from 0 --> 1: {0} pkts".format(lost_a))
print("packets lost from 1 --> 0: {0} pkts".format(lost_b))
if (lost_a == 0) and (lost_b == 0):
passed = True
else:
passed = False
except STLError as e:
passed = False
print(e)
finally:
c.disconnect()
if passed:
print("\nTest has passed :-)\n")
else:
print("\nTest has failed :-(\n")
# run the tests
simple_burst()
#!/bin/python3
# import stl_path
from tokenize import String
from unittest import result
from zipfile import Path
from trex_stl_lib.api import *
import numpy as np
from scapy.contrib.gtp import *
import time
import json
import argparse
import subprocess
from collections import defaultdict
item = defaultdict(dict)
def create_udp_pkt_flow(size, ip_min, ip_max, nflows, field):
print("{} flow will be generated...".format(nflows))
base_pkt = Ether()/IP(src="16.0.0.1", dst="192.168.101.3")/UDP(dport=12,sport=1025)
pad = max(0, size - len(base_pkt)) * 'x'
return STLPktBuilder(pkt=base_pkt/pad, vm=create_vm(ip_min, ip_max, nflows, field))
def create_gtp_pkt_flow(size, ip_min, ip_max, nflows, field):
print("{} flow will be generated...".format(nflows))
base_pkt = Ether()/IP(src="192.168.101.3", dst="192.168.101.2")/UDP(dport=2152) / \
GTP_U_Header(teid=0x00000001) / \
IP(src="192.168.101.3", dst="192.168.102.3", version=4)/UDP(dport=1234)
pad = max(0, size - len(base_pkt)) * 'x'
return STLPktBuilder(pkt=base_pkt/pad, vm=create_vm(ip_min, ip_max, nflows, field))
def create_vm(ip_min, ip_max, nflows, field):
vm = STLVM()
vm.tuple_var(name="tuple", ip_min=ip_min, ip_max=ip_max, port_min=1025, port_max=2048, limit_flows=nflows)
vm.write(fv_name="tuple.ip", pkt_offset="IP.{}".format(field))
vm.fix_chksum()
return vm
def simple_burst(streams, m, duration):
c = STLClient(server="localhost", sync_port=4501, async_port=4500)
passed = True
try:
# connect to server
c.connect()
while(1):
c.reset(ports=[0, 1])
c.add_streams(streams, ports=[0])
c.clear_stats()
c.set_port_attr(ports=[1], promiscuous=True)
c.start(ports=[0], mult=m, duration=duration)
run_mpstat(duration)
# block until done
c.wait_on_traffic(ports=[0])
# read the stats after the test
stats = c.get_stats()
item["throughput"] = float(stats[1]["rx_pps"])/1000000
item["loss"] = float(stats[0]["opackets"] - stats[1]["ipackets"])/stats[0]["opackets"]
print("")
print("Obtained Throughput: {} Mpps".format(item["throughput"]))
print("Obtained Loss Rate: {} %".format(item["loss"]))
#if (item["throughput"] > 2):
break
#print("\nTest has failed :-(\n")
#print("Error - throughput expected > 2mpps, but got {}".format(item["throughput"]))
#print("Trying again... ")
except STLError as e:
print(e)
finally:
c.disconnect()
print("\nTest has passed :-)\n")
def run_mpstat(duration):
global current_test
cmd = 'ssh upf mpstat -P ALL {} 1 -o JSON'.format(int(duration))
output = os.popen(cmd).read()
# print(json.loads(output))
item["mpstat"] = json.loads(output)
def setup_test_case(name):
global current_test
current_test = name
print("Setup TestCase: {}".format(name))
# Parse the args.
parser = argparse.ArgumentParser()
parser.add_argument('-s',
'--size',
type=int,
default=64,
help="The packets length in the stream")
parser.add_argument('-m',
'--multiplier',
default='100%',
help="The throughput in mpps on port 0 (e.g. 14mpps, 90%, 1kbps")
parser.add_argument('-d',
'--duration',
type=int,
default=10,
help="The duration of the transmission in second")
parser.add_argument('-f',
'--flows',
default='udp',
help="The flows type (i.e. udp or gtp)")
parser.add_argument('-q',
'--rx_queue',
default='12',
help="The number of RX queues")
parser.add_argument("-a",
"--auto",
help="Ignore all arguments and run in mode automatic",
action="store_true")
parser.add_argument('-p',
'--password',
default="",
help="Password of the DUT host")
args = parser.parse_args()
json_output = {
"items": []
}
current_test = ""
flow_list = [1000]
timestr = time.strftime("%Y%m%d-%H%M%S")
test_dict = {
"udp": {
"createFlows": create_udp_pkt_flow,
"testCaseName": "DownlinkMaxThoughtput",
"ipTarget": "src"
},
"gtp": {
"createFlows": create_gtp_pkt_flow,
"testCaseName": "UplinkMaxThoughtput",
"ipTarget": "dst"
}
}
test_case_name = test_dict[args.flows]["testCaseName"]
for flow in flow_list:
item = defaultdict(dict)
tx_data_rate=args.multiplier
test_case = "{}rx-{}flow-{}".format(args.rx_queue, flow, test_case_name)
item["testCase"] = test_case
setup_test_case("{}".format(test_case))
s1 = STLStream(packet=test_dict[args.flows]["createFlows"](args.size, "16.0.0.1",
"16.0.0.254", int(flow), test_dict[args.flows]["ipTarget"]), mode=STLTXCont())
simple_burst([s1], tx_data_rate, args.duration)
json_output["items"].append(item)
# for flow in flow_list:
# item = defaultdict(dict)
# for i in {0, 1}:
# tx_data_rate=0
# if i == 0:
# print("Executing with max throughput in order to find the saturation.")
# print("The packet loss and CPU load will increase!!")
# tx_data_rate=args.multiplier
# else:
# print("Executing with the target throughput in order to avoiding packet loss")
# print("The packet loss and CPU load will be fine now!!")
# tx_data_rate=str(item["throughput"]) + "mpps"
# test_case = "{}-{}-{}flow-{}rx".format(timestr, test_case_name, flow, args.rx_queue)
# # test_case = test_case_name
# item["testCase"] = test_case
# setup_test_case("{}".format(test_case))
# s1 = STLStream(packet=test_dict[args.flows]["createFlows"](args.size, "16.0.0.1",
# "16.0.0.254", int(flow), test_dict[args.flows]["ipTarget"]), mode=STLTXCont())
# simple_burst([s1], tx_data_rate, args.duration)
# if i != 0:
# json_output["items"].append(item)
reports_path = "results"
filename = "{}-{}Bytes.json".format(test_case, args.size)
file_to_open = os.path.join(reports_path, filename)
with open(file_to_open, "w") as dump_file:
json.dump(json_output, dump_file, indent=2,
separators=(',', ': '), sort_keys=True)
This diff is collapsed.
{
"gtpInterface": "enp3s0f0",
"udpInterface": "enp3s0f1"
}
{
"udpInterface": "enp3s0f0",
"gtpInterface": "enp3s0f1"
}
#create sessions if passed
# ./testbed_creator.sh <gtp/udp> <#pfcp-session> <#rules-per-session>
if test "$#" -lt 3; then
echo "Usage:"
echo "./$0 <gtp/udp> <#pfcp-session> <#rules-per-session>"
exit 1
fi
if test "$#" -eq 3; then
rm test-sessions/session*
python3 creator6.py $2 $3
fi
#remove previously attached programs
ip link set eth2 xdp off
ip link set eth3 xdp off
#Setup the network configuration for upf-bpf
curl --noproxy '*' -X POST http://localhost:1234/configure --data "@test-sessions/configure-$1.json"
#Setup the different sessions
for filename in test-sessions/session*; do
sleep 0.1
echo $filename
curl --noproxy '*' -X POST http://localhost:1234/createSession --data "@$filename"
echo ''
done
from trex_stl_lib.api import *
from scapy.contrib.gtp import *
from scapy.contrib.gtp import GTP_U_Header, GTPPDUSessionContainer
import argparse
class STLS1(object):
def create_stream(self, packet_len):
# Create base packet and pad it to size
base_pkt = Ether()/IP(src="192.168.10.10",dst="192.168.10.100")/UDP(dport=2152)/GTP_U_Header(teid=1)/GTPPDUSessionContainer(type=1, QFI=5)/IP(src="192.168.10.100",dst="192.168.20.100",version=4)/UDP(dport=12,sport=1025)
pad = max(0, packet_len - len(base_pkt)) * 'x'
vm = STLVM()
vm.tuple_var(name="tuple", ip_min="16.0.0.1", ip_max="16.0.0.254",
port_min=1025, port_max=2048, limit_flows=10000)
# write fields
vm.write(fv_name="tuple.ip", pkt_offset="IP.src")
vm.fix_chksum()
vm.write(fv_name="tuple.port", pkt_offset="UDP.sport")
pkt = STLPktBuilder(pkt=base_pkt/pad, vm=vm)
return STLStream(packet=pkt, mode=STLTXCont())
def get_streams(self, direction = 0, **kwargs):
# def get_streams(self, **kwargs):
for key, value in kwargs.items():
print("{0} = {1}".format(key, value))
packet_len = 104
# create 1 stream
return [self.create_stream(packet_len - 4)]
# dynamic load - used for trex console or simulator
def register():
return STLS1()
from trex_stl_lib.api import *
import sys
sys.path.insert(0, '/usr/local/bin/scapy')
from scapy.contrib.gtp import GTP_U_Header, GTPPDUSessionContainer
#from scapy.contrib.gtp import GTP_U_Header, GTPPDUSessionContainer
class STLS1(object):
def create_stream (self):
return STLStream(
packet = STLPktBuilder(
pkt = Ether() /
IP(src="192.168.10.10",dst="192.168.10.100") /
UDP(dport=2152) /
GTP_U_Header(teid=0x0000001) /
GTPPDUSessionContainer(type=1, QFI=5) /
IP(src="192.168.10.100",dst="192.168.20.100",version=4) /
UDP() /
Raw('x' * 20)
),
mode = STLTXCont()
)
def get_streams (self, direction = 0, **kwargs):
# create 1 stream
return [ self.create_stream() ]
# dynamic load - used for trex console or simulator
def register():
return STLS1()
from trex_stl_lib.api import *
import argparse
class STLS1(object):
def create_stream(self, packet_len):
# Create base packet and pad it to size
base_pkt = Ether()/IP(src="16.0.0.1", dst="192.168.10.100")/UDP(dport=12,sport=1025)
#dport=1234
pad = max(0, packet_len - len(base_pkt)) * 'x'
vm = STLVM()
# create a tuple var
# vm.tuple_var(name="tuple", ip_min="16.0.0.1", ip_max="16.0.0.254",
# port_min=1234, port_max=1234, limit_flows=1000)
vm.tuple_var(name="tuple", ip_min="16.0.0.1", ip_max="16.0.0.254",
port_min=1025, port_max=2048, limit_flows=1000)
# write fields
vm.write(fv_name="tuple.ip", pkt_offset="IP.src")
vm.fix_chksum()
vm.write(fv_name="tuple.port", pkt_offset="UDP.sport")
pkt = STLPktBuilder(pkt=base_pkt/pad, vm=vm)
return STLStream(packet=pkt, mode=STLTXCont())
def get_streams(self, **kwargs):
# def get_streams(self, **kwargs):
for key, value in kwargs.items():
print("{0} = {1}".format(key, value))
packet_len = 1400
# create 1 stream
return [self.create_stream(packet_len - 4)]
# dynamic load - used for trex console or simulator
def register():
return STLS1()
from trex_stl_lib.api import *
from scapy.contrib.gtp import *
class STLS1(object):
def create_stream (self):
return STLStream(
packet =
STLPktBuilder(
pkt = Ether()/IP(src="16.0.0.2",dst="48.0.0.2")/
UDP(dport=1234)/Raw('x'*20)
),
# STLPktBuilder(
# pkt = Ether()/IP(src="192.168.102.3",dst="192.168.101.3")/
# UDP(dport=1234)/Raw('x'*20)
# ),
mode = STLTXCont())
def get_streams (self, direction = 0, **kwargs):
# create 1 stream
return [ self.create_stream() ]
# dynamic load - used for trex console or simulator
def register():
return STLS1()
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